Пример #1
0
        /// <summary>
        /// retrieves a list of items that are part of the breadcrumb
        /// </summary>
        /// <param name="current"></param>
        /// <param name="overrideExcludeNavigation"></param>
        /// <returns></returns>
        public static ICollection <Item> GetBreadcrumbs(Item current, bool overrideExcludeNavigation = false)
        {
            Item homeItem = SitecoreHelper.SiteRootItem();

            List <Item> breadcrumbs = new List <Item>();

            while (current != null)
            {
                if (overrideExcludeNavigation || (current.Fields[Statics.FieldNames.ExcludeFromNavigation] != null && !((CheckboxField)current.Fields[Statics.FieldNames.ExcludeFromNavigation]).Checked))
                {
                    breadcrumbs.Add(current);
                }

                if (current == homeItem)
                {
                    break;
                }

                current = current.Parent;
            }

            breadcrumbs.Reverse();

            return(breadcrumbs);
        }
Пример #2
0
 /// <summary>
 /// Retrieves a list of items that are part of the Sites meta navigation.
 /// </summary>
 /// <returns></returns>
 public static ICollection <Item> GetMetaNavigation(Item startItem = null)
 {
     if (startItem == null)
     {
         startItem = SitecoreHelper.SiteHomeItem();
     }
     return(startItem.Children.Where(x => x.TemplateName == Statics.TemplateNames.ContentPage && !((CheckboxField)x.Fields[Statics.FieldNames.ExcludeFromNavigation]).Checked).ToList());
 }
Пример #3
0
        public static Item GetHomeReferenceItem(string fieldName)
        {
            ReferenceField reference = SitecoreHelper.SiteHomeItem().Fields[fieldName];

            if (reference != null)
            {
                return(reference.TargetItem);
            }
            return(null);
        }
Пример #4
0
 /// <summary>
 /// Retrieves the base URL of the current site in Sitecore.
 /// </summary>
 /// <param name="helper"></param>
 /// <returns></returns>
 public static string SitecoreSiteUrl(this HtmlHelper helper)
 {
     return(SitecoreExtensions.SitecoreUrl(helper, SitecoreHelper.SiteRootItem()));
 }