Skip to content

Instantly share code, notes, and snippets.

@Refactored
Created September 6, 2011 16:01
Show Gist options
  • Save Refactored/1197983 to your computer and use it in GitHub Desktop.
Save Refactored/1197983 to your computer and use it in GitHub Desktop.
Sitecore Item.IsOf
public static class SitecoreItemExtensions
{
public static bool IsOf(this Sitecore.Data.Items.Item item, Sitecore.Data.ID templateId)
{
if (item.TemplateID == templateId) return true;
foreach (Sitecore.Data.Items.TemplateItem ti in item.Template.BaseTemplates)
{
if (ti.ID == templateId) return true;
}
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment