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

Forums / Developing with Sitefinity / Custom Navigation User Control

Custom Navigation User Control

5 posts, 0 answered
  1. Mathieu
    Mathieu avatar
    13 posts
    Registered:
    21 Mar 2012
    05 Mar 2013
    Link to this post

    All,

    I`m new to SiteFinity and I<m trying to build a custom user control for my top navigation to reproduce the top nav from this site: http://wet-boew.github.com/wet-boew/demos/index-eng.html

    I will call the user control from my master page.  Unsure what SiteMapProvider to use or if I should use that.

     

    Thank you for the help and if you have example code behind to get me started would be appreciated.

    Mathieu

  2. Mathieu
    Mathieu avatar
    13 posts
    Registered:
    21 Mar 2012
    05 Mar 2013
    Link to this post

    Hi All,

     

    Well, I think I`m on to something but here is some code I tried and it didn`t crash.

    <code>protected override void Render(HtmlTextWriter writer)
            {

    SiteMapProvider oMap = SiteMapBase.GetCurrentProvider();
                SiteMapNode oMapNode;
                htmlOutput="<ul class='mb-menu'>";
                bool isfirst = true;
                oMapNode = oMap.CurrentNode;
                // foreach (SiteMapNode node in oMap.CurrentNode.ChildNodes)
                foreach (SiteMapNode node in oMapNode.ChildNodes)
                {
                    // add the children of the root site
                    //htmlOutput += renderTopLevelLink(node, isfirst, currUrl);
                    htmlOutput += "<li><div><a href='"+node.Url.ToString()+"'>"+node.Title.ToString()+"</a></div></li>";
                    isfirst = false;
                }
               htmlOutput += "</ul>";

    }

    </code>

    This code returns me all pages regardless if it is published or not and also returns the starting node which I don't want.

     

  3. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    23 Aug 2017
    08 Mar 2013
    Link to this post
    Hello,

    To build custom navigation control its best to use the datasource that sitefintiy uses SitefinitySitemapDataSource which is optimized for handling sitefinity pages and multilingual scenarious.

    <%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI.NavigationControls" TagPrefix="sfMap" %>
        
    <sfMap:SitefinitySiteMapDataSource ID="SM" runat="server" ShowStartingNode="false" />
     To hide the starting root node in the data source specify ShowStartingNode = false as highlighted.

    All the best,
    Stanislav Velikov
    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
  4. Mathieu
    Mathieu avatar
    13 posts
    Registered:
    21 Mar 2012
    08 Mar 2013 in reply to Stanislav Velikov
    Link to this post

    I've read up on that and understand that but in code behind I'm uncertain on how to call the the datasource and attach that to a sitemapnode to use is and go through it.

  5. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    16 Aug 2017
    13 Mar 2013
    Link to this post
    Hello Mathieu,

    SitefinitySiteMapDataSource is a declarative control, i.e. it would provide the datasource automatically to the control which will use it. You can then subscribe to ItemDataBound event of that control and implement some custom logic for modifying the item when it's bound to the control, since this event will fire for every item that gets bound.


    Greetings,
    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
5 posts, 0 answered