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

Forums / Developing with Sitefinity / custom navigation template

custom navigation template

2 posts, 0 answered
  1. Özkan
    Özkan avatar
    5 posts
    Registered:
    27 Sep 2012
    06 Feb 2013
    Link to this post

    Hi all,

    I wrote custom navigation template. In code behind, 'SiteMapNavigationTreeView' control was binded. If a page ShowInNavigation flag's 'false', don't want to show in navigation. If sitemap depth bigger than 2, It cause problem. How to unvisible?

    Here is my .cs code :

     protected void Page_Load(object sender, EventArgs e)
        {       
            SiteMapNode smn = SiteMapBase.GetCurrentProvider().CurrentNode;

            while (smn.ParentNode != null)
            {
                if (smn.ParentNode.ParentNode == SiteMap.RootNode)
                { 
                    siteMapControl_verticaltree.DataSource = getNodes(smn);
                    siteMapControl_verticaltree.DataBind();
                  
                    break;
                }

                smn = smn.ParentNode;
            }
        }

        protected SiteMapNodeCollection getNodes(SiteMapNode smn)
        {
            SiteMapNodeCollection col = new SiteMapNodeCollection();

            for (int i = 0; i < smn.ParentNode.ChildNodes.Count; i++)
            {
                if (((Telerik.Sitefinity.Web.PageSiteNode)(smn.ParentNode.ChildNodes[i])).ShowInNavigation)
                {
                    col.Add(smn.ParentNode.ChildNodes[i]);
                }
            }

            return col;
        }

    ---------------------------------------------------------------------------------
    asp.x

     <sf:ConditionalTemplate ID="ConditionalTemplate8" Left="NavigationMode" Operator="Equal"
                Right="VerticalTree" runat="server">
                <navcontrols:SiteMapNavigationTreeView runat="server" ID="siteMapControl_verticaltree"
                    Skin="Sitefinity">
                </navcontrols:SiteMapNavigationTreeView>
            </sf:ConditionalTemplate>
    -----------------------




  2. Randy Hodge
    Randy Hodge avatar
    96 posts
    Registered:
    03 Nov 2014
    08 Feb 2013
    Link to this post
    Hello Özkan,

    My recommendation would be to use SitefinitySiteMapDataSource, because it's based on asp.net SiteMapDataSource, and it also handles the information about permissions applied to pages, their ShowInNavigation property and culture. It will always return the correct pages.

    Greetings,
    Randy Hodge
    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
2 posts, 0 answered