How should I retrieve all frontend navigation pages?

Posted by Community Admin on 04-Aug-2018 19:59

How should I retrieve all frontend navigation pages?

All Replies

Posted by Community Admin on 25-Mar-2015 00:00

 

 

PageManager pageManager = PageManager.GetManager();
                var rootNodeId = SiteInitializer.CurrentFrontendRootNodeId;
                IQueryable<PageData> pages = pageManager.GetPageDataList()
                    .Where(pData => pData.NavigationNode.Parent.Id == rootNodeId
                    && !pData.NavigationNode.IsDeleted
                    && pData.NavigationNode.ShowInNavigation == true
                    && pData.Status == ContentLifecycleStatus.Live).Order
 
By(pData => pData.NavigationNode.Ordinal);

 This will work fine as long as the top level pages are not redirect pages which in my case is the issue.  I have tried playing around with pData.NavigationNode.NodeType == NodeType.InnerRedirect...and etc., but no luck so far to get those pages to show up in the menu.

 

How should I go about doing this?

 The menu structure is this:

About Us -> top level redirect page set to Overview

 - Overview -> child page

 -another child page

 

Posted by Community Admin on 26-Mar-2015 00:00

After realizing I was being stubborn I decided to go through with using SiteMapBase.  I am still getting all finalized to the way I need it, but I am well on my way this the following approach.

 

var provider = SiteMapBase.GetCurrentProvider();
var rootNode = provider.FindSiteMapNodeFromKey(rootNodeId.ToString());
var pages = provider.GetChildNodes(rootNode);
 
foreach (PageSiteNode node in pages)
  //Still working on items in here
   var subPages = provider.GetChildNodes(node);
   foreach (PageSiteNode subNode in subPages)
  
    //Still working on items in here too
  

This thread is closed