+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / How should I retrieve all frontend navigation pages?

How should I retrieve all frontend navigation pages?

2 posts, 0 answered
  1. Stacey
    Stacey avatar
    291 posts
    Registered:
    18 Oct 2012
    25 Mar 2015
    Link to this post

     

     

    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

     

  2. Stacey
    Stacey avatar
    291 posts
    Registered:
    18 Oct 2012
    26 Mar 2015 in reply to Stacey
    Link to this post

    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
      }
    }

2 posts, 0 answered