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

Site PanelBar

6 posts, 2 answered
  1. Richard
    Richard avatar
    77 posts
    Registered:
    24 Oct 2007
    09 Jun 2010
    Link to this post
    Hello,
    At the moment the SitePanelBar shows everything on the site like so:

    Page Group 1
       page 1.1
       page 1.2
       Page Group 2  (nested page group)
            Page 2.1
            Page 2.2
    Page 3
    Page 4
    etc.

    When on the page 2.2., is there anyway of hiding the parent items i.e. only show the following on the navigation:
    Page Group 2  (nested page group)
            Page 2.1
            Page 2.2

    And also, is there a way to add return to parent link like so :
    Page Group 2  (nested page group)
            Page 2.1
            Page 2.2
    Return above Page Group 2


    The objective would be to create a dynamic navigation bar that is contextual.
    Thanks
    R
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    09 Jun 2010
    Link to this post
    Hi Richard,

    The SiteMap is hierarchical structure - if you hide the parent the childs will be hidden as well. You could disable the root items or apply some css class to the so that they will not appear.  Below is a sample code

    var currentNode = SiteMap.CurrentNode as CmsSiteMapNode;
       if (currentNode != null)
       {
           if (currentNode.Parent.Parent != null)
           {
               ICmsPage parent = cmsManager.GetPage(currentNode.Parent.Parent.PageID) as ICmsPage;
               if (parent != null && parent.PageType == CmsPageType.Group)
               {
                   RadPanelItem item = RadPanelbar1.FindItemByText(cmsManager.GetPage(parent.ID).Name);
                   if (item != null)
                       // or set a css
                       item.Enabled = false;
                        // here you need to get all child pages and disable them.
     
                   ICmsPage currentItemParent = cmsManager.GetPage(currentNode.Parent.PageID) as ICmsPage;
                   RadPanelItem returnItem = new RadPanelItem("Retun to " + currentItemParent.MenuName, currentItemParent.StaticUrl);
                   RadPanelItem pitem = RadPanelbar1.FindItemByText(cmsManager.GetPage(currentItemParent.ID).Name);
                   pitem.Items.Add(returnItem);
     
               }
     
           }
       }
     

    You can use while to reach the parent instead of calling currentNode.Parent.Parent. Another option would be to binding the control manually based on the current SiteMap node


    All the best,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
    Answered
  3. Richard
    Richard avatar
    77 posts
    Registered:
    24 Oct 2007
    10 Jun 2010
    Link to this post
    Dim currentNode As CmsSiteMapNode = SiteMap.CurrentNode
         If Not currentNode Is Nothing Then
             Literal1.Text &= "You are in " & currentNode.Title & "<br/>"
             For Each tmpNode As SiteMapNode In currentNode.ChildNodes
                 Literal1.Text &= tmpNode.Title & "<br/>"
             Next
             Literal1.Text &= "Above " & currentNode.Title & " is " & currentNode.ParentNode.Title
         End If

    Thanks for the info.

    I decided to create my own navigation bar for personal reasons.
    Just in case anyone is interested I have provided a bit of VB code.

    A further question if I may:  if I ever needed to include "hidden from navigation" nodes how do I do so please? The "currentNode.ChildNodes" does not seem to include them.  Thanks

    Rich

  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    10 Jun 2010
    Link to this post
    Hello Richard,

    You have to bind the navigation control to a data source other than the site map provider. You can take a look at this forum thread: http://www.sitefinity.com/devnet/forums/sitefinity-3-x/developing-with-sitefinity/manager-getpages-sorting-based-on-ordinal-second-attempt.aspx

    Best wishes,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  5. Richard
    Richard avatar
    77 posts
    Registered:
    24 Oct 2007
    10 Jun 2010
    Link to this post

    Thank you.

    I'm having a bit of trouble with the VB version.  Any chance you have a clue on the issue?

    Private Sub LoadNodes()
        Dim manager As New CmsManager()
        Dim AllPages As IList = manager.GetPages()
        Dim newColl = AllPages.Cast(Of ICmsPage)().ToList()
        newColl.Sort(Function(x, y) x.Ordinal.CompareTo(y.Ordinal))
    End Sub

    VS2010 says that "cast" (in AllPages.Cast) is not a member of 'System.Collections.IList, do you know what I am supposed to use this in VB? Thanks
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    10 Jun 2010
    Link to this post
    Hi Richard,

    Make sure that you have imported System.Linq

    Imports Telerik.Web.UI
    Imports Telerik.Cms
    Imports System.Linq
     
     
    Partial Class CustomControls_SiteTreeViewVB
        Inherits System.Web.UI.UserControl
     
     
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
            If Not Page.IsPostBack Then
                LoadNodes()
            End If
        End Sub
     
        Protected Sub RadTreeView1_NodeDataBound(ByVal sender As Object, ByVal e As RadTreeNodeEventArgs)
            Dim p As ICmsPage = DirectCast(e.Node.DataItem, ICmsPage)
            e.Node.ToolTip = p.MenuName
        End Sub
     
        Private Sub LoadNodes()
            manager = New CmsManager()
            Dim AllPages As IList = manager.GetPages()
            Dim newColl = AllPages.Cast(Of ICmsPage)().ToList()
            newColl.Sort(Function(x, y) x.Ordinal.CompareTo(y.Ordinal))
            RadTreeView1.DataTextField = "MenuName"
            RadTreeView1.DataFieldID = "ID"
            RadTreeView1.DataFieldParentID = "ParentID"
            RadTreeView1.DataNavigateUrlField = "StaticUrl"
            RadTreeView1.DataSource = newColl
            RadTreeView1.DataBind()
        End Sub
     
        Private manager As CmsManager
    End Class


    All the best,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
    Answered
Register for webinar
6 posts, 2 answered