More in this section

Forums / Developing with Sitefinity / Breadcrumb Template and Levels not working properly

Breadcrumb Template and Levels not working properly

7 posts, 1 answered
  1. Matt
    Matt avatar
    42 posts
    Registered:
    25 Jan 2012
    02 Jan 2013
    Link to this post

    Hello,

    I have added a breadcrumb widget to a page template and have modified the template to use the following for testing purposes.  The problem is, no matter how deep in the site the page is that is using this template, it always uses the node template for Level="0". Am I misunderstanding how Levels work?  I would like to use different HTML in my breadcrumb depending on what level of the site the page is on.


    <%@ Control Language="C#" %>
    <%@ Register Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" TagPrefix="telerik" %>
    <%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI" TagPrefix="sf" %>
     
    <div class="sfBreadcrumbWrp">
        <sf:SitefinityLabel id="BreadcrumbLabel" runat="server" WrapperTagName="span" HideIfNoText="true" CssClass="sfBreadcrumbLabel" />
        <telerik:RadSiteMap runat="server" ID="Breadcrumb" Skin="Sitefinity" >
           
           
           
          <LevelSettings>
            <telerik:SiteMapLevelSetting Level="0" MaximumNodes="2" ListLayout-RepeatDirection="Horizontal"  Layout="Flow"  >
                <NodeTemplate>
                    0
                </NodeTemplate>
            </telerik:SiteMapLevelSetting>
             <telerik:SiteMapLevelSetting Level="1" MaximumNodes="2" ListLayout-RepeatDirection="Horizontal"  Layout="Flow"  >
                <NodeTemplate>
                    1
                </NodeTemplate>
            </telerik:SiteMapLevelSetting>
             <telerik:SiteMapLevelSetting Level="2" MaximumNodes="2" ListLayout-RepeatDirection="Horizontal"  Layout="Flow"  >
                <NodeTemplate>
                    2
                </NodeTemplate>
            </telerik:SiteMapLevelSetting>
             <telerik:SiteMapLevelSetting Level="3" MaximumNodes="2" ListLayout-RepeatDirection="Horizontal"  Layout="Flow"  >
                <NodeTemplate>
                    3
                </NodeTemplate>
            </telerik:SiteMapLevelSetting>
             <telerik:SiteMapLevelSetting Level="4" MaximumNodes="2" ListLayout-RepeatDirection="Horizontal"  Layout="Flow"  >
                <NodeTemplate>
                    4
                </NodeTemplate>
            </telerik:SiteMapLevelSetting>
          </LevelSettings
      </telerik:RadSiteMap>
    </div>

  2. Jen Peleva
    Jen Peleva avatar
    568 posts
    Registered:
    10 Nov 2016
    07 Jan 2013
    Link to this post
    Hello Matt,

    I believe you misunderstood the idea of the SiteMap control and its nodetemplates. What they do is to set different appearance to SiteMap items from different levels. So for example, if you have this SiteMap as datasource:

    <?xml version="1.0" encoding="utf-8" ?>
       
        <siteMapNode title="Products" >
          <siteMapNode title="ASP.NET AJAX Controls" category="ASPNET">
            <siteMapNode title="BreadcrumbPage" url="~/BreadcrumbPage.aspx" >
              <siteMapNode title="Hello World"/>
            </siteMapNode>
            <siteMapNode title="Demos" />
            <siteMapNode title="Videos" />
          </siteMapNode>
     </siteMapNode>
    and this is your markup:

    <telerik:RadSiteMapDataSource runat="server" ID="RadSiteMapDataSource1" SiteMapFile="~/Examples.sitemap">
            </telerik:RadSiteMapDataSource>
            <telerik:RadSiteMap runat="server" ID="Breadcrumb4" DataSourceID="RadSiteMapDataSource1">
            <DefaultLevelSettings MaximumNodes="3">
        </DefaultLevelSettings>
        <LevelSettings>
            <telerik:SiteMapLevelSetting Level="0" MaximumNodes="4">
            <NodeTemplate>
                            0
                            <%# DataBinder.Eval(Container.DataItem, "title") %></h3>
                        </NodeTemplate>
            </telerik:SiteMapLevelSetting>
        </LevelSettings>
     
        <LevelSettings>
            <telerik:SiteMapLevelSetting Level="1" MaximumNodes="4">
            <NodeTemplate>
                            1
                            <%# DataBinder.Eval(Container.DataItem, "title") %></h3>
                        </NodeTemplate>
            </telerik:SiteMapLevelSetting>
        </LevelSettings>
     
         <LevelSettings>
            <telerik:SiteMapLevelSetting Level="2" MaximumNodes="4">
            <NodeTemplate>
                            2
                            <%# DataBinder.Eval(Container.DataItem, "title") %></h3>
                        </NodeTemplate>
            </telerik:SiteMapLevelSetting>
        </LevelSettings>
     
        <LevelSettings>
            <telerik:SiteMapLevelSetting Level="3" MaximumNodes="4">
            <NodeTemplate>
                            3
                            <%# DataBinder.Eval(Container.DataItem, "title") %></h3>
                        </NodeTemplate>
            </telerik:SiteMapLevelSetting>
        </LevelSettings>
            </telerik:RadSiteMap>
    You will get the rendering from the attached image.
    If this is what you would like to achieve you're only missing the default settings in your SiteMap declaration:
    <DefaultLevelSettings MaximumNodes="3">
        </DefaultLevelSettings>

    Kind regards,

    Jen Peleva
    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
  3. Matt
    Matt avatar
    42 posts
    Registered:
    25 Jan 2012
    07 Jan 2013 in reply to Jen Peleva
    Link to this post

    Hi Jen,

    Thanks for the reply.  That is what I am trying to achieve, however I am not using a xml datasource. I don't specify one so by default I believe it's using the sites structure which is what I want.  So I have have the following pages in my site, I would like to control the html at each level, but when I modify the template as shown in my original post, it's always using the HTML in the node template for Level 0.  It never uses Level 1 or 2 no matter what page I'm on.  So does it have something to do with the fact that I'm not using an XML datasource?

    Home

    >> SubPage1

    >>SubPage2

    >>>>SubSubPage2

       

  4. Jen Peleva
    Jen Peleva avatar
    568 posts
    Registered:
    10 Nov 2016
    08 Jan 2013
    Link to this post
    Hello Matt,

    I've tested the Sitemap Breadcrumb as a user control, which binds to SitefinitySiteMapdataSource and it works properly. It updates each level, depending on the template, which is set to it. Here's the markup of my user control:

    <sf:SitefinitySiteMapDataSource ID="SiteMapDataSource1" runat="server"  />
        <sf:SitefinityLabel id="BreadcrumbLabel" runat="server" WrapperTagName="span" HideIfNoText="true" CssClass="sfBreadcrumbLabel" />
        <telerik:RadSiteMap runat="server" ID="Breadcrumb1"   DataSourceID ="SiteMapDataSource1"  >
        <DefaultLevelSettings MaximumNodes="3">
        </DefaultLevelSettings>
        <LevelSettings>
            <telerik:SiteMapLevelSetting Level="0" MaximumNodes="4">
            <NodeTemplate>
                            0
                            <%# DataBinder.Eval(Container.DataItem, "title") %></h3>
                        </NodeTemplate>
            </telerik:SiteMapLevelSetting>
        </LevelSettings>
     
        <LevelSettings>
            <telerik:SiteMapLevelSetting Level="1" MaximumNodes="4">
            <NodeTemplate>
                            1
                            <%# DataBinder.Eval(Container.DataItem, "title") %></h3>
                        </NodeTemplate>
            </telerik:SiteMapLevelSetting>
        </LevelSettings>
     
         <LevelSettings>
            <telerik:SiteMapLevelSetting Level="2" MaximumNodes="4">
            <NodeTemplate>
                            2
                            <%# DataBinder.Eval(Container.DataItem, "title") %></h3>
                        </NodeTemplate>
            </telerik:SiteMapLevelSetting>
        </LevelSettings>
     
        <LevelSettings>
            <telerik:SiteMapLevelSetting Level="3" MaximumNodes="4">
            <NodeTemplate>
                            3
                            <%# DataBinder.Eval(Container.DataItem, "title") %></h3>
                        </NodeTemplate>
            </telerik:SiteMapLevelSetting>
        </LevelSettings>
      </telerik:RadSiteMap>
     Notice the the data source - SitefinitySitemapDatasource.  It is responsible for handling all the necessary logic concerning pages that are marked as ShowInNavigation = "false", page permissions, group pages etc. It can be configured to output the whole frontend sitemap, but also supports standard SiteMapDataSource features like StartingNodeOffset, StartFromCurrentNode, StartingNodeUrl etc, so this is exactly the dataSource we use for out SiteMap.

    Greetings,
    Jen Peleva
    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
    Answered
  5. Matt
    Matt avatar
    42 posts
    Registered:
    25 Jan 2012
    08 Jan 2013 in reply to Jen Peleva
    Link to this post

    Hi Jen,

    This looks exactly like what I need, I also need the added flexibility that StartingNodeOffset and StartFromCurrentNode would provide.  I am having trouble getting this to work though.  I have modified my template to include your two highlighted tags but I get an error stating :Both DataSource and DataSourceID are defined on 'Breadcrumb'.  

    I am more of a designer than a developer so I may be getting in over my head here.  Does code behind need to be modifed to get this to work?  Please let me know.

    Thanks!

    Matt

  6. Jen Peleva
    Jen Peleva avatar
    568 posts
    Registered:
    10 Nov 2016
    09 Jan 2013
    Link to this post
    Hello Matt,

    I believe the problem comes from the fact that you're using the markup as a template for the breadcrumb control when the breadcrumb control already has a datasource. Can you try to register the provided code as a user control in Sitefinity and check if it would work then? 

    Greetings,
    Jen Peleva
    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
  7. Matt
    Matt avatar
    42 posts
    Registered:
    25 Jan 2012
    10 Jan 2013 in reply to Jen Peleva
    Link to this post
    Yes Jen, you were correct. I created a user control and it worked great.
    Thanks for your help!!

    Matt
7 posts, 1 answered