예제 #1
0
        public static HtmlString ChildNodes(this IDocumentNode IDocumentNode, int atLevel = 0, bool includeHidden = false, bool includeDeleted = false)
        {
            var ul = new HtmlTags.HtmlTag("ul");

            ul.AddClass("topnavigation");

            foreach (var c in IDocumentNode.AncestorAtLevel(atLevel).Children.Where(n => (includeDeleted || !n.IsDeleted) && (includeHidden || !n.IsHidden)))
            {
                var li = new HtmlTags.HtmlTag("li");
                if (IDocumentNode.IsDescendantOrSameAs(c))
                {
                    li.AddClass("selected");
                }
                li.Add("a").Attr("href", c.Url).Text(c.Name);
                ul.Children.Add(li);
            }
            return(new HtmlString(ul.ToHtmlString()));
        }
예제 #2
0
        public static HtmlTag ChildNodesRecursiveHtmlTag(this IDocumentNode currentNode, IDocumentNode IDocumentNode, int allExpandToLevel = 2, bool includeHidden = false, bool includeDeleted = false, string addAdminPath = "")
        {
            var ul = new HtmlTags.HtmlTag("ul");

            foreach (var c in IDocumentNode.Children.Where(n => (includeDeleted || !n.IsDeleted) && (includeHidden || !n.IsHidden)))
            {
                var li = new HtmlTags.HtmlTag("li");

                var path = addAdminPath + c.Url;

                li.Add("a").Attr("href", path).Text(c.Name);
                if (c == currentNode)
                {
                    li.AddClass("selected");
                }
                if (c.IsDescendantOrSameAs(currentNode))
                {
                    li.AddClass("sel");
                }
                if (c.Children.Count > 0 && (c.Level < allExpandToLevel || c.IsDescendantOrSameAs(currentNode) || currentNode.IsDescendantOrSameAs(c)))
                {
                    li.Children.Add(ChildNodesRecursiveHtmlTag(currentNode, c, allExpandToLevel, includeHidden, includeDeleted, addAdminPath));
                }
                ul.Children.Add(li);
            }
            return(ul);
        }