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

Forums / Developing with Sitefinity / Two navigation menu's, on sitemap

Two navigation menu's, on sitemap

7 posts, 0 answered
  1. Daniel Plomp
    Daniel Plomp avatar
    952 posts
    Registered:
    18 Feb 2004
    26 Sep 2007
    Link to this post
    Hello telerik,

    I've created my navigation structure inside Sitefinity. I have a r.a.d.menu that is on top of the page, showing the menu items.

    I also want a r.a.d.menu on the bottom of the page, showing just a few menu items from the same sitemap.

    I have a Page Group named Other that contains for sub-items. These sub-items I want to show on the bottom menu.

    Is this possible? Can I filter out some pages that are beneath the Page Group Other?

    Thanks,
    Daniel
  2. Pepi
    Pepi avatar
    981 posts
    Registered:
    28 Oct 2016
    27 Sep 2007
    Link to this post
    Hello Daniel,

    A possible solution is to create a method that returns all child nodes of the given Group Page. For example:

        private IList<SiteMapNode> GetChildNodes() 
        { 
            IList<SiteMapNode> list = new List<SiteMapNode>(); 
            foreach (SiteMapNode sitemapnode in SiteMap.RootNode.ChildNodes) 
            { 
                CmsSiteMapNode node = sitemapnode as CmsSiteMapNode; 
                if (node != null && node.CmsPage.PageType == CmsPageType.Group && (node.CmsPage.Name == "Other" || node.CmsPage.Title == "Other")) 
                { 
                    foreach (SiteMapNode childnode in node.ChildNodes) 
                    { 
                        list.Add(childnode); 
                    } 
                } 
            } 
     
            return list; 
        } 

    And after that you need to bind the menu control with the newly created data source:

    protected void Page_Load(object sender, EventArgs e) 
        {  
            if (!Page.IsPostBack) 
            { 
               this.RadMenu1.DataSource = this.GetChildNodes(); 
               this.RadMenu1.DataTextField = "Title"
               this.RadMenu1.DataValueField = "Url"
               this.RadMenu1.DataBind(); 
            } 
        } 

    Another solution is to implement your own SiteMapProvider (a class inheriting SiteMapProvider) that will be used for the custom site navigation.

    Hope this is helpful.

    All the best,
    Pepi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. Daniel Plomp
    Daniel Plomp avatar
    952 posts
    Registered:
    18 Feb 2004
    27 Sep 2007
    Link to this post
    Hello Pepi,

    Thanks for this suggestion. I've implemented it and it works almost. Problem is I have set the Page Group to non-visible. Means that it is not in the ChildNodes collection of the RootNode.

    Can I force to get all the nodes, visible or not-visible?

    Thanks,
    Daniel
  4. Pepi
    Pepi avatar
    981 posts
    Registered:
    28 Oct 2016
    27 Sep 2007
    Link to this post
    Hello Daniel,

    If you mean that the given Page Group is not included in navigation then you could not get its child nodes through the SiteMap because in fact this page is not a part of site navigation and doesn't exist as a node in SiteMap. You could try to use CmsManager for accessing child pages of the invisible Group Page. For example:

    protected void Page_Load(object sender, EventArgs e) 
        {  
            if (!Page.IsPostBack) 
            { 
               thisthis.RadMenu1.DataSource = this.GetChildNodes(); 
               this.RadMenu1.DataTextField = "MenuName"
               this.RadMenu1.DataNavigateUrlField = "StaticUrl"
               this.RadMenu1.DataBind(); 
            } 
        } 
     
    private IList<ICmsPage> GetChildNodes() 
        { 
            IList<ICmsPage> list = new List<ICmsPage>(); 
            CmsManager manager = new CmsManager();

            foreach (IPage page in manager.GetPages()) 
            { 
                if (page is ICmsPage && ((ICmsPage)page).PageType == CmsPageType.Group && ((ICmsPage)page).Title != "Other") 
                { 
                    foreach (ICmsPage child in ((ICmsPage)page).Pages) 
                    { 
                        list.Add(child); 
                    } 
                } 
            } 
     
            return list; 
        } 

    Hope this helps.

    Sincerely yours,
    Pepi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  5. Gratian
    Gratian avatar
    9 posts
    Registered:
    05 Nov 2010
    16 Sep 2011
    Link to this post
    Hi,
    Great post ! (if i would have found it 2 days ago it would have been even greater :D ).
    I have 2 problems though:

    1. can i sort the pages based on their location in administration (so if home is first and contact second they will be loaded into the list in that order) - is the ordinal attribute the one that is set when i drag a node up or down the witemap tree view?

    2. i think that if you have a multi-language site and do manager.GetPages() it will take all the pages for all the languages so a language check will be needed.

  6. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    02 Dec 2016
    21 Sep 2011
    Link to this post
    Hi Gratian,

    1. Yes, as you have properly pointed out we use the ordinal property to correctly order the pages as they are presented in the backend. You'll just need to make sure that the control you'll be feeding with this datasource supports hierarchical datasource, otherwise it will not be able to present it in the desired manner.
    2.  You can get the pages with

    CmsManager cmsManager = new CmsManager();
    var p = cmsManager.GetPage(param.Id) as ICmsPage;

    The page has a LanguageVersions property, which contains the data for it multilingual content, co you can say:

    foreach (KeyValuePair<int, IPageContent> pageLanguage in p.LanguageVersions)
    {
     //...
    }


    Best wishes,
    Boyan Barnev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Gratian
    Gratian avatar
    9 posts
    Registered:
    05 Nov 2010
    22 Sep 2011
    Link to this post
    Thanks,
    I got it working and it's really great to have a seccond menu for the current language selected in the order of the administration sitemap tree.

Register for webinar
7 posts, 0 answered