Exemplo n.º 1
0
        private static void ClassifyAnchors(ContentItem startsFrom, ContentItem current, N2.Web.Tree tree)
        {
            IList <ContentItem> ancestors = GenericFind <ContentItem, ContentItem> .ListParents(current, startsFrom, true);

            if (ancestors.Contains(startsFrom))
            {
                ancestors.Remove(startsFrom);
            }
            tree.LinkWriter((n, w) =>
            {
                var link   = n.Current.Link();
                var @class = n.Current == current ? "current" : ancestors.Contains(n.Current) ? "trail" : "";
                if (n.Children.Count > 0)
                {
                    @class += " dropdown-toggle";
                    link.Attribute("data-toggle", "dropdown");
                }
                link.Class(@class).WriteTo(w);
            });
            tree.ULTagModifier((n, t) =>
            {
                if (n.Parent != null && n.Parent.Current != null)
                {
                    t.MergeAttribute("class", "dropdown-menu");
                }
            });
            tree.LITagModifier((n, t) =>
            {
                //if children, indicate with a dropdown class
                var @class = n.Children.Count > 0 ? "dropdown" : string.Empty;
                @class    += " " + (n.Current == current
                                ? "active"
                                : ancestors.Contains(n.Current) ? "active trail" : "");
                t.MergeAttribute("class", @class.Trim());
            });
        }
 public static ContentItem FindStartPageOf(ContentItem item)
 {
     return(GenericFind <ContentItem, ContentItem> .ClosestOf <IStartPage>(item));
 }
 public static LanguageRoot FindLanguageRootOf(ContentItem item)
 {
     return((LanguageRoot)GenericFind <ContentItem, ContentItem> .ClosestOf <LanguageRoot>(item));
 }