Beispiel #1
0
        private static ISiteStructureNode GetStructureNode(CmsPage cmsPage, ISiteStructureNode root)
        {
            foreach (var childNode in root.ChildNodes)
            {
                if (childNode.PageId == cmsPage.ContentId)
                {
                    return(childNode);
                }

                var found = GetStructureNode(cmsPage, childNode);
                if (found != null)
                {
                    return(found);
                }
            }

            return(null);
        }
        private static void AttachChildNodes(ISitemapNode sitemapNode, ISiteStructureNode node, string path, Dictionary <Guid, CmsPage> allPages)
        {
            foreach (var childStructureNode in node.ChildNodes)
            {
                var childSitemapNode = new SitemapNode();

                if (!allPages.ContainsKey(childStructureNode.PageId))
                {
                    continue;
                }

                childSitemapNode.Page        = allPages[childStructureNode.PageId];
                childSitemapNode.VirtualPath = new Uri(path + "/" + childSitemapNode.Page.Slug, UriKind.Relative);
                sitemapNode.ChildNodes.Add(childSitemapNode);

                AttachChildNodes(childSitemapNode, childStructureNode, childSitemapNode.VirtualPath.ToString(), allPages);
            }
        }