v4.1 Breadcrumb Issue
Hi guys,
I'm posting here rather than opening a support ticket as I could do with a quick response and hopefully someone already has a solution.
I created a breadcrumb control using the sample code within the forum, since upgrading to 4.1 it no longer displays.
My code is as follows:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Breadcrumb.ascx.cs" Inherits="Controls_Breadcrumb" %><asp:SiteMapPath runat="server" ID="Breadcrumbs" RenderCurrentNodeAsLink="true" PathSeparator=" > " OnItemCreated="Breadcrumbs_ItemCreated" NodeStyle-Font-Bold="true" NodeStyle-Font-Size="12px" NodeStyle-ForeColor="#737373" CurrentNodeStyle-ForeColor="#1183dd" NodeStyle-Font-Underline="false" PathSeparatorStyle-Font-Bold="true" PathSeparatorStyle-Font-Size="10px" PathSeparatorStyle-ForeColor="#737373" CssClass="breadcrumbControl"></asp:SiteMapPath>using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;public partial class Controls_Breadcrumb : System.Web.UI.UserControl protected void Page_Load(object sender, EventArgs e) protected void Breadcrumbs_ItemCreated(object sender, SiteMapNodeItemEventArgs e) if ((e.Item.ItemIndex == 0) && (e.Item.ItemType == SiteMapNodeItemType.Root) && (e.Item.Controls.Count > 0)) if (e.Item.Controls[0] is HyperLink) ((HyperLink)e.Item.Controls[0]).Text = "Home"; ((HyperLink)e.Item.Controls[0]).ToolTip = ""; else if (e.Item.ItemType == SiteMapNodeItemType.Current) if (e.Item.Controls[0] is Literal) Telerik.Sitefinity.Web.PageSiteNode pageSiteNode = (Telerik.Sitefinity.Web.PageSiteNode)e.Item.SiteMapNode; Telerik.Sitefinity.Modules.Pages.PageManager manager = new Telerik.Sitefinity.Modules.Pages.PageManager(); Telerik.Sitefinity.Pages.Model.PageNode pageNode = manager.GetPageNode(pageSiteNode.Id); ((Literal)e.Item.Controls[0]).Text = pageNode.Title.Value; Hi Richard, welcome to Sitefinity 4x....
The SiteMapPath has been broken for a while now and no fix in sight...
http://www.sitefinity.com/devnet/forums/sitefinity-4-x/general-discussions/internal-build-sitemappath-and-radsitemap-not-working.aspx
Check that post for discussion on what I think is same issue.
Cheers,
Phill
Thanks Phill,
Looking in at the PITS it's said to be resolved although I can see your comment that it is still not working. Can someone from Telerik please comment to see if this is being looked into.
I can't understand why something so common which was previously in previous versions and something that is common on most sites has been missed out in the first place.
Hi,
I use this code and may help you.
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Breadcrumb.ascx.cs" Inherits="SitefinityWebApp.Controls.Breadcrumbs" %><a href="/">Home</a> » <asp:Repeater runat="server" ID="rep1"> <ItemTemplate> <asp:HyperLink runat="server" ID="nodelink1" /> <asp:Literal runat="server" ID="literalsep"></asp:Literal> </ItemTemplate></asp:Repeater>using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using Telerik.Sitefinity.Web;using Telerik.Sitefinity.Configuration;using Telerik.Sitefinity.Modules.Pages.Configuration; namespace SitefinityWebApp.Controls public partial class Breadcrumbs : System.Web.UI.UserControl protected override void OnInit(EventArgs e) protected void Page_Load(object sender, EventArgs e) var configManager = Config.GetManager(); var config = configManager.GetSection<PagesConfig>(); var id = config.HomePageId; var currentNode = SiteMapBase.GetActualCurrentNode(); List<PageSiteNode> list = new List<PageSiteNode>(); //list.Add(currentNode); if (currentNode.PageId != id) //homepage list.Add(currentNode); while (currentNode.ParentNode != null && currentNode.ParentNode.Title != "Pages") currentNode = currentNode.ParentNode as PageSiteNode; list.Add(currentNode); list.Reverse(); rep1.DataSource = list; rep1.ItemDataBound += new RepeaterItemEventHandler(rep1_ItemDataBound); rep1.DataBind(); void rep1_ItemDataBound(object sender, RepeaterItemEventArgs e) if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) var link = e.Item.FindControl("nodelink1") as HyperLink; var l = e.Item.FindControl("literalsep") as Literal; var node = e.Item.DataItem as PageSiteNode; link.Text = node.Title; link.NavigateUrl = node.Url; if (l != null) l.Text = " » "; Thanks mkavici, that works a treat. Much appreciated.
Excellent post just about to add a support ticket for no breadcrumb.
Should have taken advice and stayed with 3.7 also. 4.1 is much faster to develop the templating side but missing some core features that 3.7 had.
Thanks mkavici for sharing. Much appreciated.
I'm trying to add the news/blog title to the end of this breadcrumbs plugin for the last few hours but still can't figure out. uggghh. Did anyone got that part to work and would like to share?