Custom Navigation Questions - Bugs & Issues - Bugs & Issues - Progress Community
 Bugs & Issues

Custom Navigation Questions

  • Custom Navigation Questions
  • I have a custom navigation template like the following.

    <%@ Control Language="C#" AutoEventWireup="true" %>
    <telerik:RadTabStrip ID="RadPanelbarNav" runat="server" Visible="false" />
      
    <asp:Repeater  ID="Repeater1" runat="server" DataSourceID="SiteMapDataSource" >
        <HeaderTemplate>
            <ul class="nav-holder">
        </HeaderTemplate>
        <ItemTemplate>
                <li>
                    <a href='<%# Eval("Url") %>' runat='server'>
                        <h3><%#Eval ("Title") %></h3>
                        <p><%# Eval("Description") %></p>
                    </a>
                </li>
        </ItemTemplate>
        <FooterTemplate>
            </ul>
        </FooterTemplate>
    </asp:Repeater>
      
    <asp:SiteMapDataSource runat="server" ID="SiteMapDataSource" StartingNodeOffset="0" ShowStartingNode="false" />



    How can I make this work so that when I select "do not show in navigation" under the page options the page will not show up in the custom navigation. It seems that the idatasource ignores this option.
  • Hello Jonathan,

    By default SitemapDataSource will return all nodes and then you can filter the ones who are marked not to be shown in Navigation from the code-behind. For more information on how to achieve this you can refer to the sample code I've attached.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Telerik.Sitefinity;
    using Telerik.Sitefinity.Web;
     
    namespace SitefinityWebApp.Controls
        public partial class WebUserControl1 : System.Web.UI.UserControl
        
            protected void Page_Load(object sender, EventArgs e)
            
     
              Repeater1.ItemDataBound += new RepeaterItemEventHandler(Repeater1_ItemDataBound);
              Repeater1.DataBind();
                 
            
     
            void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
            
     
                if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
                
     
                    var data = e.Item.DataItem as PageSiteNode;
                    if (data != null)
                    
     
                        if (data.ShowInNavigation == false)
                        
                            e.Item.Visible = false;
                        
                    
                
            
        
    If you need any further assistance with this implementation, please write back.

    All the best,
    Boyan Barnev
    the Telerik team

  • 283952_panelbar.PNG
    Hey Boyan,
      How would you implement this with a RadPanelBar?  I'm noticing that if you hide items on ItemDataBound you get undesirable results

    Lets say you have a structure like this

    - Parent
       - Child

    If the Child gets visible set to false like the code you defined because of show-in-navigation being false...then the PanelBar Parent still has the Expand\Collapse arrows like it has Children.

    (see attached)

  • Hello Steve,

    Yes, you are right on that one. In this case I'd recommend you to get  alist of pages using the Fluent/native API and then pass this list as a DataSource to PanelBar. In the filter expression you can get only these pages that have ShoInNavigation == true. For more information o how to bind the RadPanelBar to this list of pages, please take a look at this article from our documentation.

    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
  • 284193_nav2.PNG
    Thanks Boyan,

    What am I missing here?

    protected void Page_Load(object sender, EventArgs e)
        var pages = App.WorkWith()
           .Pages()
           .ThatArePublished()
           .LocatedIn(Telerik.Sitefinity.Fluent.Pages.PageLocation.Frontend)
           .Where(p => p.ShowInNavigation == true)
           .OrderBy(p => p.Ordinal)
           .Get();
     
        navPanelBar.DataSource = pages;
        navPanelBar.DataBind();

    <telerik:RadPanelBar ID="navPanelBar" runat="server"
        Skin="OCFP"
        EnableEmbeddedSkins="false"
        DataFieldParentID="ParentId"
        DataFieldID="Id"
        DataTextField="Title"
        OnItemDataBound="OnPageNode_ItemDataBound"
        AllowCollapseAllItems="false"
        MaxDataBindDepth="5"
        Width="256px">
        <ExpandAnimation Type="None" />
        <CollapseAnimation Type="None" />
    </telerik:RadPanelBar>

    It's not rendering anything...if I use "LocatedIn"...and the attached image is what I get if I remove the LocatedIn line

  • Hi Steve,

    Actually the problem seems to be in the DataSource that you're binding the PanelBar to. When you declare DataFieldParentID="ParentId" in the PanelBar template it's expecting to receive all PageNodes with ParentId property different from null. However, if you filter only pages .LocatedIn(Telerik.Sitefinity.Fluent.Pages.PageLocation.Frontend) this would construct the list without the "Pages" root node (it's the same as specifying .GetPageNodes().Where(pN => pN.RootNode.Id == SiteInitializer.FrontendRootNodeId). What you can do if filter out the Backend PageNodes and the Backend RootNode in the lambda expression. Please refer to the below sample:

    public partial class PanelBarCustom : System.Web.UI.UserControl
        
            protected void Page_Load(object sender, EventArgs e)
            
                var source = App.WorkWith().Pages()
                    //.LocatedIn(Telerik.Sitefinity.Fluent.Pages.PageLocation.Frontend)
                                           .ThatArePublished()
                                           .Where(p => p.ShowInNavigation == true && p.IsBackend == false && p.Id != SiteInitializer.BackendRootNodeId)
                                           .Get()
                                           .ToList();
     
                PanelBarControl.DataSource = source;
                PanelBarControl.DataTextField = "Title";
                PanelBarControl.DataFieldID = "Id";
                PanelBarControl.DataFieldParentID = "ParentId";
                PanelBarControl.DataBind();
                 
                        
            
        
    and ascx:
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="PanelBarCustom.ascx.cs" Inherits="SitefinityWebApp.Controls.PanelBarCustom" %>
    <telerik:RadPanelBar runat="server" ID="PanelBarControl" ></telerik:RadPanelBar>

    I hope this helps you achieve the desired functionality. If any problems persist, please do not hesitate to contact us again.

    All the best,
    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
  • Ahhh I figured it much be something like that :)  My next step was to just get "Pages" as the starting node.

    I am curious though...is this a Fluent Bug?...or current limitation

    I mean...
    .LocatedIn(Telerik.Sitefinity.Fluent.Pages.PageLocation.Frontend) == p.IsBackend == false
    Right?...are they not the same thing?

    Here's what I'm saying....when I tell it I just want the frontend pages with .LocatedIn()...I would ASSUME that SiteInitalizer.BackendRootNodeID wouldn't be taken into effect since I just told it I want only front-end pages.

    Perhaps another method to wrap this "p.Id != SiteInitializer.BackendRootNodeId" ?  Or an override on LocatedIn?
  • Hello Steve,

    Yes, you are right - .LocatedIn(Telerik.Sitefinity.Fluent.Pages.PageLocation.Frontend) is not the same as p.IsBackend == false as it will still leave out the "Backend" root node in the PageNodes list, that's why I'm excluding it additionally with p.Id != SiteInitializer.BackendRootNodeId. However this is not an API limitation for sure, maybe I didn't express myself properly in the previous post - the problem is coming from the fact that when you declare a DataFieldParentID property (which you definitely need, otherwise you'll get a flat structure of the current pages) you need to have the FrontendRootNodeId present in the list since it's the ParentId of all Frontend pages, that's why applying the .LocatedIn filter returns an empty PanelBar - it cannot bind itself to a list of pages that are missing the ParentId.

    Kind regards,
    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
  • I attempted the same DataBound method that Boyan suggested in an earlier post. I had problems filtering out unpublished pages, and found this newer post (http://www.sitefinity.com/devnet/forums/sitefinity-4-x/general-discussions/unpublished-page-showing-up-in-custom-navigation-after-4-2-upgrade.aspx) that recommends using the SitefinitySiteMapDataSource control. This solved all my problems with trying to create a custom navigation control.

    <%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI.NavigationControls" TagPrefix="navcontrols" %>
     
    <telerik:RadPanelBar runat="server" ID="SitemapPanelbar" DataSourceID="SiteMapDataSource" Width="180px" Skin="Simple" ></telerik:RadPanelBar>
     
    <navcontrols:SitefinitySiteMapDataSource ID="SiteMapDataSource" runat="server" StartingNodeOffset="1" ShowStartingNode="false"  />
  • I am trying to figure out how to use the "user" configuration / selected pages from the Navigation editor.  But unfortunately knows how to do this.  Is the source code available so I can research how the built in navigation stuff works?


  • Hello Tom Miller,

    Can you please let us know what is the ultimate result you want to achieve? I'm asking because it woud be very simple if you just specify the datasource through our built-in navigation control (i.e. select the custom range of pages to be included) and then use your own template for that control, which would allow you to represent it as per your desired functionality. Please do not hesitate to let us know if the functionality you demand differs from what I've offered. Just in case I'm attaching a short video demonstrating how to apply and external template to the Navigation widget in Sitefinity, hope you might find it useful.

    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
  • I want to use the Navigation control settings with a custom navigator layout / css.   I got what I wanted with doing a lot of messing around with css, but assume I did it the hard way.

    I am using the Simplicity free skin.  The custom navigation is only for the top level pages.  This is fine for the front page, but I want a similarly looking navigation else where. 

    Secondly, is there a way to register these custom navigation as controls, or selections from the available menu options so I don't have to have non tech users figure out a long path name to stick in just the right places.

    I am new with Sitefinity and looking to learn as much as I can.

    Thanks.
  • Hi Tom Miller,

    Thank you for the clarification. Using an external template for the navigation is the easiest way to achieve this in terms of development efforts, as you're using the built-in designer of the navigation control, and are simply specifying how to represent the selected data on the frontend. However, it's possible to create a completely separate user controls with their custom logic and register them as widgets in the toolbox like the others. For more information you can check this article from our online documentation.

    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
  • HI,
    Thanks for the info.  The thing I am still missing is how to create a template for a navigation control.  I found this article, but there no built in template for navigation. 

    www.sitefinity.com/.../mapping_external_templates_for_sitefinity_4_widgets.aspx

    Any chance you could provide a simple example one for me?
    Thanks.