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

Forums / General Discussions / Breadcrumbs in SF4

Breadcrumbs in SF4

35 posts, 1 answered
  1. chris_cf
    chris_cf avatar
    32 posts
    Registered:
    04 Jul 2007
    02 Oct 2010
    Link to this post
    Hi,

    Do I have to create a widget for Breadcrumbs now that it is not included in SF4.0?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    03 Oct 2010
    Link to this post
    Hello Chris,

    You can use the standard ASP.NET SiteMapPath control and it will display navigation path of your website.

    <asp:SiteMapPath ID="SiteMapPath1" Runat="server"></asp:SiteMapPath>

    We will consider including the control in toolbox section by default.

    Regards,
    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. chris_cf
    chris_cf avatar
    32 posts
    Registered:
    04 Jul 2007
    05 Oct 2010
    Link to this post
    Thanks!
  4. Andrei
    Andrei avatar
    553 posts
    Registered:
    27 Nov 2008
    13 Dec 2010
    Link to this post
    Ivan,

    I tried that and it does not display the current node. Is it me or is there a problem with the sitefinity site map.

    Many thanks,
    Andrei
  5. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    15 Dec 2010
    Link to this post
    Hi Andrei,

    I managed to reproduce the behavior with missing current node in the latest release. You can try using this code which should fox the issue

    1. Template

    <asp:SiteMapPath ID="SiteMapPath1" runat="server" RenderCurrentNodeAsLink="true" >
     <CurrentNodeTemplate>
      <asp:HyperLink runat="server" ID="CurrentNodeLink"></asp:HyperLink>
     </CurrentNodeTemplate>
    </asp:SiteMapPath>


    2. Code behind

    protected void Page_Load(object sender, EventArgs e)
       {
     
           this.SiteMapPath1.ItemCreated += new SiteMapNodeItemEventHandler(SiteMapPath1_ItemCreated);
     
       }
     
     
     void SiteMapPath1_ItemCreated(object sender, SiteMapNodeItemEventArgs e)
       {
           if (e.Item.ItemType == SiteMapNodeItemType.Current)
           {
     
               var currentNode = GetCurrentPageNode();
               var link  = e.Item.FindControl("CurrentNodeLink") as HyperLink;
               link.Text = currentNode.UrlName;
               link.NavigateUrl = currentNode.UrlName;
           }
       }
     
     
       public static PageSiteNode GetCurrentPageNode()
       {
           PageSiteNode result = null;
           result = SiteMapBase.GetCurrentProvider().CurrentNode as PageSiteNode;
           if (result != null)
           {
               result = SiteMapBase.GetFirstPageDataNode(result);
           }
     
           return result;
       }


    Greetings,
    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
  6. Andrei
    Andrei avatar
    553 posts
    Registered:
    27 Nov 2008
    16 Dec 2010
    Link to this post
    Ivan,

    That worked just fine. Will I need the fix with the full release, or is it just a bug?

    Many thanks,
    Andrei
    ---------------
    P.S. How do people mark a post as "answer"???
  7. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    16 Dec 2010
    Link to this post
    Hello Andrei,

    We will have a breadcrumb control in Q1 or Q2, until then you need to use this solution.

    Greetings,
    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
  8. Michael H.
    Michael H. avatar
    16 posts
    Registered:
    10 Nov 2007
    20 Dec 2010
    Link to this post
    After reviewing several threads the following worked for my RC v4.0.992.0. Allowing for the current node Name field (Title property) to be displayed as well as the correct Url. Also removed the "Pages >" start node and added CssClass styling option.

    Alot of thanks to others from: http://www.sitefinity.com/devnet/forums/sitefinity-4-x/general-discussions/asp-sitemappath-not-rendering-correctly.aspx

    1. Template

    <asp:SiteMapPath ID="SiteMapPath1" runat="server" RenderCurrentNodeAsLink="true" >
     <CurrentNodeTemplate>
      <asp:HyperLink runat="server" ID="CurrentNodeLink"></asp:HyperLink>
     </CurrentNodeTemplate>
    </asp:SiteMapPath>

    2. Code behind

    protected void Page_Load(object sender, EventArgs e)
    {
    }
      
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        SiteMapPath1.SkipLinkText = String.Empty;
        SiteMapPath1.CssClass = CssClass;
        SiteMapPath1.ItemCreated += new SiteMapNodeItemEventHandler(SiteMapPath1_ItemCreated);
    }
      
      
    [CssClassProperty]
    public string CssClass
    { get; set; }
      
      
    void SiteMapPath1_ItemCreated(object sender, SiteMapNodeItemEventArgs e)
    {
        if (e.Item.ItemType == SiteMapNodeItemType.PathSeparator)
            e.Item.CssClass = CssClass + "Separator";
        else
            e.Item.CssClass = CssClass + "Link";
      
        // hide the root node, and it's following path separator
        if (e.Item.ItemIndex == 0 || (e.Item.ItemIndex == 1 && e.Item.ItemType == SiteMapNodeItemType.PathSeparator))
        {
            e.Item.Visible = false;
        }
        else if (e.Item.ItemType == SiteMapNodeItemType.Current)
        {
            using (var sf = App.WorkWith())
            {
                var pageNode = sf.Page().PageManager.GetPageNode(
                    ((Telerik.Sitefinity.Web.PageSiteNode)e.Item.SiteMapNode).Id);
      
                var link = e.Item.FindControl("CurrentNodeLink") as HyperLink;
                link.Text = pageNode.Title.Value;
                link.NavigateUrl = (e.Item.SiteMapNode).Url.Replace("~/", "/");
            }
        }
    }
  9. Orion
    Orion avatar
    54 posts
    Registered:
    02 Feb 2009
    21 Dec 2010
    Link to this post
    Hi,

    I attempted to recreate what you stated above and I was able to successfully add the control to my toolbox.  But when I try to drag the new control onto my page, I get the following error:

    Could not load type 'SitefinityWebApp.Controls.CustomBreadcrumb'.

    I'm not really a programmer and I don't want to bother my developers with this, but I'm really not sure what I did wrong.

    Here's the exact code in my template:
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="CustomBreadcrumb.ascx.cs"
        Inherits="SitefinityWebApp.Controls.CustomBreadcrumb" %>
     
    <asp:SiteMapPath ID="SiteMapPath1" runat="server" RenderCurrentNodeAsLink="true" >
     <CurrentNodeTemplate>
      <asp:HyperLink runat="server" ID="CurrentNodeLink"></asp:HyperLink>
     </CurrentNodeTemplate>
    </asp:SiteMapPath>

    And here's the code in my code behind:
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using Telerik.Sitefinity;
    using Telerik.Sitefinity.Abstractions;
    using Telerik.Sitefinity.Configuration;
    using Telerik.Sitefinity.GenericContent.Model;
    using Telerik.Sitefinity.Libraries.Model;
    using Telerik.Sitefinity.Model;
    using Telerik.Sitefinity.Modules.Pages.Configuration;
    using Telerik.Sitefinity.Security.Model;
    using Telerik.Sitefinity.Services;
    using Telerik.Web.UI;
     
    namespace SitefinityWebApp.Controls
    {
        public partial class CustomBreadcrumb : System.Web.UI.UserControl
        {
            protected void Page_Load(object sender, EventArgs e)
            {
            }
     
            protected override void OnInit(EventArgs e)
            {
                base.OnInit(e);
                SiteMapPath1.SkipLinkText = String.Empty;
                SiteMapPath1.CssClass = CssClass;
                SiteMapPath1.ItemCreated += new SiteMapNodeItemEventHandler(SiteMapPath1_ItemCreated);
            }
     
     
            [CssClassProperty]
            public string CssClass
            { get; set; }
     
     
            void SiteMapPath1_ItemCreated(object sender, SiteMapNodeItemEventArgs e)
            {
                if (e.Item.ItemType == SiteMapNodeItemType.PathSeparator)
                    e.Item.CssClass = CssClass + "Separator";
                else
                    e.Item.CssClass = CssClass + "Link";
     
                // hide the root node, and it's following path separator
                if (e.Item.ItemIndex == 0 || (e.Item.ItemIndex == 1 && e.Item.ItemType == SiteMapNodeItemType.PathSeparator))
                {
                    e.Item.Visible = false;
                }
                else if (e.Item.ItemType == SiteMapNodeItemType.Current)
                {
                    using (var sf = App.WorkWith())
                    {
                        var pageNode = sf.Page().PageManager.GetPageNode(
                            ((Telerik.Sitefinity.Web.PageSiteNode)e.Item.SiteMapNode).Id);
     
                        var link = e.Item.FindControl("CurrentNodeLink") as HyperLink;
                        link.Text = pageNode.Title.Value;
                        link.NavigateUrl = (e.Item.SiteMapNode).Url.Replace("~/", "/");
                    }
                }
            }
     
        }
    }
  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    21 Dec 2010
    Link to this post
    Hi Orion,

    The control is not registered properly. Please take a look at this post.

    Kind regards,
    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
  11. Orion
    Orion avatar
    54 posts
    Registered:
    02 Feb 2009
    21 Dec 2010
    Link to this post
    I actually used that link to learn how to register new controls but I'm apparently doing something wrong.  I'm attaching a screenshot of the parameters I currently have in place on this control.

    Can you see something missing or wrong?  I tried eliminating the space from the name and title fields but that hasn't made a difference yet.
  12. Michael H.
    Michael H. avatar
    16 posts
    Registered:
    10 Nov 2007
    22 Dec 2010
    Link to this post
    I received a similar error at first and rebuilding the project in Visual Studio seemed to work. Telerik might be able to comment with a better solution though.
  13. Orion
    Orion avatar
    54 posts
    Registered:
    02 Feb 2009
    22 Dec 2010
    Link to this post
    Fantastic!  Thank you so much.  Not being a programmer myself I had no idea I could just "rebuild" the project like that.  I'm never let down by the Sitefinity community.
  14. Orion
    Orion avatar
    54 posts
    Registered:
    02 Feb 2009
    22 Dec 2010
    Link to this post
    So the current node is rendering but what if you don't want it to be a hyperlink?  I feel like since you're already on that page, it's pretty typical for for that text in the breadcrumb to not be a hyperlink.

    I tried modifying this text in the template: RenderCurrentNodeAsLink="false" but that didn't seem to work.

    Does anybody know how to modify the code I used above to remove the link from the current node?


    Thanks!
  15. Michael H.
    Michael H. avatar
    16 posts
    Registered:
    10 Nov 2007
    26 Dec 2010
    Link to this post
    Code to render the current node as a Label rather than a HyperLink.

    1. Template

    <asp:SiteMapPath ID="SiteMapPath1" runat="server" RenderCurrentNodeAsLink="false" >
     <CurrentNodeTemplate>
      <asp:Label runat="server" ID="CurrentNodeItem"></asp:Label>
     </CurrentNodeTemplate>
    </asp:SiteMapPath>

    2. Code Behind

    protected void Page_Load(object sender, EventArgs e)
    {
    }
     
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        SiteMapPath1.SkipLinkText = String.Empty;
        SiteMapPath1.CssClass = CssClass;
        SiteMapPath1.ItemCreated += new SiteMapNodeItemEventHandler(SiteMapPath1_ItemCreated);
    }
     
    [CssClassProperty]
    public string CssClass
    { get; set; }
     
    void SiteMapPath1_ItemCreated(object sender, SiteMapNodeItemEventArgs e)
    {
        if (e.Item.ItemType == SiteMapNodeItemType.PathSeparator)
            e.Item.CssClass = CssClass + "Separator";
        else
            e.Item.CssClass = CssClass + "Link";
     
        // hide the root node, and it's following path separator
        if (e.Item.ItemIndex == 0 || (e.Item.ItemIndex == 1 && e.Item.ItemType == SiteMapNodeItemType.PathSeparator))
        {
            e.Item.Visible = false;
        }
        else if (e.Item.ItemType == SiteMapNodeItemType.Current)
        {
            using (var sf = App.WorkWith())
            {
                var pageNode = sf.Page().PageManager.GetPageNode(
                    ((Telerik.Sitefinity.Web.PageSiteNode)e.Item.SiteMapNode).Id);
     
                var currentNode = e.Item.FindControl("CurrentNodeItem") as Label;
                currentNode.Text = pageNode.Title.Value;
            }
        }
    }

  16. Orion
    Orion avatar
    54 posts
    Registered:
    02 Feb 2009
    29 Dec 2010
    Link to this post
    That worked perfectly!  Thank you very much.
  17. Jeffrey
    Jeffrey avatar
    17 posts
    Registered:
    11 Nov 2010
    09 Feb 2011
    Link to this post
    Hey Ivan,

    Has there been a date set for the release of the breadcrumb control? I have a project due at the end of March and I'm wondering if I should wait or try using the code work-around.

    Thanks,

    Jeff
  18. Kalina
    Kalina avatar
    176 posts
    Registered:
    27 Oct 2016
    14 Feb 2011
    Link to this post
    Hi Jeffrey,

    The implementation of this feature is scheduled for Q2 due in July.
    Please, use the suggested workaround.

    Greetings,
    Kalina
    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
  19. Dan Sorensen
    Dan Sorensen avatar
    256 posts
    Registered:
    13 Aug 2010
    15 Feb 2011
    Link to this post
    How do I add, "Home" to the beginning of the breadcrumb chain in this example code?
  20. ZK
    ZK avatar
    23 posts
    Registered:
    23 Nov 2010
    18 Mar 2011
    Link to this post
    FYI: This no longer appears to work in the latest internal build. My sitemappath has completely disappeared.
  21. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    18 Mar 2011
    Link to this post
    Hello Zak,

    Can you put a VS debugger point in ItemCreated and see whether there are items? If so, then the problem is in the logic you copied.


    Greetings,
    Ivan Dimitrov
    the Telerik team
  22. ZK
    ZK avatar
    23 posts
    Registered:
    23 Nov 2010
    22 Mar 2011
    Link to this post
    There are apparently no items, as I never hit the breakpoint.
  23. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    25 Mar 2011
    Link to this post
    Hi Zak,

    Subscribe for the event from the template OnItemCreated and the code you use should work. There are some issues when you do this from the code behind.

    Greetings,
    Ivan Dimitrov
    the Telerik team
  24. Armen
    Armen avatar
    11 posts
    Registered:
    07 Feb 2008
    25 Apr 2011
    Link to this post
    Hi Ivan,

    I am using the last version of Sitefinity.

    I have tried with both cases and it is not firing the ItemCreated event. Do you have any idea what can be the issue?

    Thanks,
    Armen
  25. Drew Greenwell
    Drew Greenwell avatar
    66 posts
    Registered:
    11 Feb 2010
    25 Apr 2011
    Link to this post
    Same here. Our breadcrumbs have stopped working in sitefinity 4.1.   We have tried wiring this up in the template, in the codebehind, and both.. None are working. Break points are hit in page load and init, but ItemCreated is never hit. Renaming the method in the codebehind while it is declared in the ascx file causes the compilation error you would expect ("SiteMap_ItemCreated does not exist"). But a breakpoint inside of SiteMap_ItemCreated never gets hit.
  26. Phill Hodgkinson
    Phill Hodgkinson avatar
    362 posts
    Registered:
    10 Nov 2004
    25 Apr 2011
    Link to this post
    @Drew, I don't have the post handy but SiteMapPath is broken in Sitefinity 4.1 upgrade.

    You can get around it by building it manually, not a real solution as the whole reason for paying for a CMS is that it's supposed to do this stuff already.

    If I come across the post that has the manual solution (provided by Telerik) I'll post it here for you.

    Cheers,
    Phill
  27. Drew Greenwell
    Drew Greenwell avatar
    66 posts
    Registered:
    11 Feb 2010
    25 Apr 2011
    Link to this post
    Thanks Phil, I appreciate the heads up. This looks like the post in question.

    http://www.sitefinity.com/devnet/forums/sitefinity-4-x/general-discussions/internal-build-sitemappath-and-radsitemap-not-working.aspx

    Thanks again,
    Drew
  28. Phill Hodgkinson
    Phill Hodgkinson avatar
    362 posts
    Registered:
    10 Nov 2004
    26 Apr 2011
    Link to this post
    Yes, that was the post I was thinking of. Pretty amazing that this bug got introduced, not sure how they didn't notice something like this.
  29. Nelson
    Nelson avatar
    14 posts
    Registered:
    29 Dec 2010
    07 Jul 2011
    Link to this post
    A Breadcrumbs widget is now available on the Sitefinity Marketplace!

    http://www.sitefinity.com/marketplace/modules/breadcrumbs-widget.aspx
  30. Garry
    Garry avatar
    52 posts
    Registered:
    04 Nov 2010
    31 Aug 2011
    Link to this post
    Nelson,
    Thanks for letting us know about the Breadcrumb control, but is there now a Breadcrumb control in 4.2 or not? If I have to I can use a third party breadcrumb control, but seeing this is pretty standard these days I'm surprised if it is not there yet as Q2 has come and gone. I hate having to rely on yet another company/developer to update their stuff as the Sitefinity version moves on.

    However if it is in 4.2 I am not finding it. 

    Thanks,
    Garry  
35 posts, 1 answered
1 2