Ejemplo n.º 1
0
        public static CMS.PageCollection GetHierarchicalPageCollection(int parentID)
        {
            sortedPages   = new PageCollection();
            unSortedPages = new PageCollection().Load();

            foreach (CMS.Page item in unSortedPages)
            {
                if (item.ParentID == parentID)
                {
                    item.Level = 0;
                    //check the role for validity
                    sortedPages.Add(item);
                    LoadChildItem(item);
                }
            }

            return(sortedPages);
        }
Ejemplo n.º 2
0
    ListItemCollection GetPageHierarchy()
    {
        CMS.PageCollection pages = CMS.ContentService.GetHierarchicalPageCollection();

        if (pageHierarchy == null)
        {
            pageHierarchy = new ListItemCollection();
            lstHierarchy.Items.Clear();
            ListItem item;
            foreach (CMS.Page page in pages)
            {
                string lvlIndicator = string.Empty;
                for (int i = 0; i < page.Level; i++)
                {
                    lvlIndicator += " - ";
                }

                item = new ListItem(lvlIndicator + page.Title, page.PageID.ToString());

                pageHierarchy.Add(item);
            }
        }
        return(pageHierarchy);
    }
Ejemplo n.º 3
0
        /// <summary>
        /// Loads up a Page Collection in hierarchical fashion with each level of the tree
        /// specified by the "Level" field.
        /// </summary>
        /// <returns></returns>
        public static CMS.PageCollection GetHierarchicalPageCollection()
        {
            sortedPages = new PageCollection();
            unSortedPages = new PageCollection().Load();

            foreach (CMS.Page item in unSortedPages) {
                if (item.ParentID == null) {
                    item.Level = 0;
                    //check the role for validity
                    sortedPages.Add(item);
                    LoadChildItem(item);
                }
            }

            return sortedPages;
        }
Ejemplo n.º 4
0
    public override SiteMapNode BuildSiteMap()
    {
        lock (_lock) {
            // Return immediately if this method has been called before
            if (_root != null)
            {
                return(_root);
            }

            CMS.PageCollection links = new CMS.PageCollection().Load();

            //top level node
            _root = new SiteMapNode(this, "0", "~/default.aspx", "Home", "Return to main page", null, null, null, null);
            AddNode(_root, null);

            //you can change this as needed
            string rewrittenDirectory = "~/view/";


            foreach (CMS.Page link in links)
            {
                string[] rolelist = null;
                if (!String.IsNullOrEmpty(link.Roles))
                {
                    rolelist = link.Roles.Split(new char[] { ',', ';' }, 512);
                }

                if (link.ParentID == null)
                {
                    SiteMapNode node = new SiteMapNode(this, link.PageID.ToString(), rewrittenDirectory + link.PageUrl, link.MenuTitle, link.Summary, rolelist, null, null, null);
                    AddNode(node, _root);
                }
            }

            //add in the child nodes
            foreach (CMS.Page link in links)
            {
                string[] rolelist = null;
                if (!String.IsNullOrEmpty(link.Roles))
                {
                    rolelist = link.Roles.Split(new char[] { ',', ';' }, 512);
                }
                if (link.ParentID != null)
                {
                    // Create a SiteMapNode
                    SiteMapNode node       = new SiteMapNode(this, link.PageID.ToString(), rewrittenDirectory + link.PageUrl, link.MenuTitle, link.Summary, rolelist, null, null, null);
                    SiteMapNode parentNode = null;
                    //loop the nodes to find the parent
                    foreach (CMS.Page link2 in links)
                    {
                        if (link2.PageID == link.ParentID)
                        {
                            parentNode = new SiteMapNode(this, link2.PageID.ToString(), rewrittenDirectory + link2.PageUrl, link2.MenuTitle, link2.Summary, rolelist, null, null, null);
                            break;
                        }
                    }
                    AddNode(node, parentNode);
                }
            }


            return(_root);
        }
    }
Ejemplo n.º 5
0
 static bool PageHasChildren(int pageID)
 {
     CMS.PageCollection collCheck = GetHierarchicalPageCollection(pageID);
     return(collCheck.Count > 0);
 }