Skip to content

Instantly share code, notes, and snippets.

View adamhopkinson's full-sized avatar

Adam Hopkinson adamhopkinson

View GitHub Profile
@adamhopkinson
adamhopkinson / gist:8036875
Last active August 10, 2017 12:43
C# Globablisation - getting the market instance from the visitors' origin country (via GeoIP)
var market = MarketInfo.Markets.SingleOrDefault(m => m.Code == Visitor.CountryCode);
if (market == null)
market = Visitor.Market;
@adamhopkinson
adamhopkinson / gist:8026627
Last active December 31, 2015 18:28
Getting a Sitecore item url in a C# repeater
<ul>
<asp:Repeater ID="rpFooterDestinations" runat="server">
<ItemTemplate>
<li>
<a href="<%# Sitecore.Links.LinkManager.GetItemUrl(
(Sitecore.Data.Items.Item) Container.DataItem
) %>"><%# Eval("DisplayName") %></a>
</li>
</ItemTemplate>
</asp:Repeater>
@adamhopkinson
adamhopkinson / gist:7792041
Created December 4, 2013 17:40
Quick c# list foreach
ids.ForEach(id => {
itineraries.Add(Sitecore.Context.Database.GetItem(id));
});
@adamhopkinson
adamhopkinson / gist:7791592
Created December 4, 2013 17:19
Defaulting a sitecore query to a blank list
List<Item> items = (Sitecore.Context.Item.Axes.SelectItems(query) ?? new Item[] { }).ToList();