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

Forums / Developing with Sitefinity / Custom Navigation (SiteMenu)

Custom Navigation (SiteMenu)

10 posts, 0 answered
  1. mInNaL
    mInNaL avatar
    7 posts
    Registered:
    18 Jun 2008
    09 Jul 2009
    Link to this post
    Hi,

    I want to make my own custom navigation in SiteFinity 3.6 instead of the existing SiteMenu toolbar.

    Anybody please give me an example of how do I iterate through all the pages and find the selected page/root etc.

    Please provide me an ASCX and ASCX.CS example, so I can work further with it.

    Best regards,
    Princely


  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    09 Jul 2009
    Link to this post
    Hi mInNaL,

    SiteMenu is a web user control that has RadMenu declaration in it. To get the current selected node from the site map you can add the following logic on Page_Load event.

      protected void Page_Load(object sender, EventArgs e) 
        { 
            rm1.DataBind(); 
            CmsSiteMapNode node = SiteMap.CurrentNode as CmsSiteMapNode; 
            if (node != null
            { 
            } 
        } 

    control template:

    <asp:SiteMapDataSource ID="ds1" runat="server" ShowStartingNode="false" /> 
     
    <telerik:RadMenu ID="rm1" runat="server" DataSourceID="ds1" /> 


    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. mInNaL
    mInNaL avatar
    7 posts
    Registered:
    18 Jun 2008
    09 Jul 2009
    Link to this post
    Thank you very much for your reply.
    It was just a part of it.

    What I need is:

    I) I want to iterate through all the pages in SiteFinity and build my own navigation
    2) Have to check the following in my iteration:
         * node name (menu label)
         * ShowInNavigation (true/false)
         * Is it a childnode
         * if it is a child node, what is the parent node


    Best regards,
    Princely
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    09 Jul 2009
    Link to this post
    Hi mInNaL,

    Below is a sample code that gets a ICms page and its properties.

     
            ICmsPage page = cmsPage as ICmsPage; 
            CmsManager manager = new CmsManager(); 
            IList listofPages = manager.GetPages(); 
            foreach (ICmsPage p in listofPages) 
            { 
                
                foreach (RadMenuItem item in RadMenu1.GetAllItems()) 
                    if (item != null && item.Text.Equals("Test")) 
                    { 
                        ICmsPage mypage = manager.GetPage(p.ID) as ICmsPage; 
                        if (mypage !=null
                        { 
                            Response.Write(mypage.MenuName); 
                            //mypage.Navigable - returns whether the page is visible or not 
                        } 
                    } 
            } 

    You can get the Parent from e.Item.Items or e.Item.Parent.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. mInNaL
    mInNaL avatar
    7 posts
    Registered:
    18 Jun 2008
    09 Jul 2009
    Link to this post
    When I put your code in my UserControl I get error on these two lines:

    ICmsPage

     

    page = cmsPage as ICmsPage;

     

    foreach

     

    (RadMenuItem item in RadMenu1.GetAllItems())
     

     

     

     

    cmsPage and RadMenu1, giving me the error "doesnt exist in the current context"

    What I have to put other than:

    using

     

    System;

     

     

    using System.Data;

     

    using System.Configuration;

     

    using System.Collections;

     

    using System.Web;

     

    using System.Web.Security;

     

    using System.Web.UI;

     

    using System.Web.UI.WebControls;

     

    using System.Web.UI.WebControls.WebParts;

     

    using System.Web.UI.HtmlControls;

     

    using System.ComponentModel;

     

    using System.Drawing;

     

    using

     

    Telerik;

     

     

    using Telerik.Cms;

     

    using Telerik.Cms.Web;

     

    using Telerik.Web.UI;

     

    using Telerik.Caching;

     

    using Telerik.Cms.Web.UI;

     

  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    09 Jul 2009
    Link to this post
    Hello mInNaL,

    cmsPage - it is CmsSiteMapNode ( you can get the SiteMap.CurrentNode or e.Item.DataItem)
    RadMenu1 - is the ID or RadMenu control that should be declared in your control template.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  7. mInNaL
    mInNaL avatar
    7 posts
    Registered:
    18 Jun 2008
    09 Jul 2009
    Link to this post
    Ok, I have maybe put my question in a wrong way... now I will try to do it.

    What I need is, In my MasterPage "Page_Load" event, I want to iterate through all the pages in the site and draw my own navigation.

    How do I approach this?

    Would you please send me the example for:

    How to put in "My.Master" file and the "My.Master.cs"


    Best regards,
    Princely

  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    10 Jul 2009
    Link to this post
    Hi mInNaL,

    What I need is, In my MasterPage "Page_Load" event, I want to iterate through all the pages in the site and draw my own navigation.

    What is the idea of loping through all pages? Which one will be included and which one will be removed? You should create some identifier. You can just show or hide some nodes after you bind RadMenu ( or another navigation control) control in Page_Load. Then check the e.Item - whether it should be included or not.

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  9. mInNaL
    mInNaL avatar
    7 posts
    Registered:
    18 Jun 2008
    10 Jul 2009
    Link to this post
    The reason for I want to loop all the pages is, I want to build my own navigation (totally custom made with my own styles/tags etc. without using skins etc.)

    So, for that, I need to loop every pages and find out, which page is disabled/enabled and whether a page is a root page or subpage etc.

    Would you please provide me an example with, how to approach this?
  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    10 Jul 2009
    Link to this post
    Hi mInNaL,

    You can use the code samples I sent in the previous posts.  Just add the code to Page Load event of the master page/ user control. Then call DataBind method of the RadMenu ( or another control you are going to use).

    I suggest that you should use user/custom control and then add this control to your Master page, instead of hadrcoding the logic in Page_Load event in the Master page.

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Register for webinar
10 posts, 0 answered