I’ve written about this before, but really it was just an addendum to another point I was trying to make. It might be worth bringing out as a post in itself.
ASP.NET navigation controls take data from a navigation provider, and render it into HTML. The breadcrumbs used in SharePoint use the one navigation control, but give it different navigation providers…
… the point relevant to whether or not the “> Pages > default.aspx” is displayed in the breadcrumbs is the SiteMapProvider. The CurrentNavSiteMapProviderNoEncode provider doesn’t seem to include the ‘Pages’ bit of the path - hence it is used by the page layouts. The Default.master’s SPContentMapProvider provides a breadcrumb that includes the ‘Pages’.
So, if your page is using a breadcrumb such as…
<asp:SiteMapPath id="ContentMap" SiteMapProvider="SPContentMapProvider" SkipLinkText="" NodeStyle-CssClass="ms-sitemapdirectional" runat="server"/>
… then your breadcrumb will include the “> Pages > default.aspx”. Note that this is the default content of the breadcrumb in default.master. Thus, if you’re creating a brand new page layout, you’ll probably want to override that content using an ASP.NET Content control something like this…
<asp:Content ContentPlaceHolderId="PlaceHolderTitleBreadcrumb" runat="server">
<asp:SiteMapPath ID="siteMapPath" SiteMapProvider="CurrentNavSiteMapProviderNoEncode" RenderCurrentNodeAsLink="false" SkipLinkText="" NodeStyle-CssClass="ms-sitemapdirectional" Runat="server"/>
</asp:Content>
This code defines a content control that overrides the default content for the Title Breadcrumb. It uses the CurrentNavSiteMapProviderNoEncode (nice name!) navigation provider, and so won’t show the “> Pages > default.aspx” bit in the breadcrumb.
So, in short, when you’re creating a new Page Layout, make sure you override the Title Breadcrumb with something that uses the CurrentNavSiteMapProviderNoEncode provider.
Hi Andy,
Thanks for the article. It almost solved my problem and saved lot of time. Thanks for the efforts you have put in.
I’m facing another problem with this now. At site collection level it just displays “Home” at all the times on all the publishing pages. It works fine for subsite. e.g for Products site it displays it like this “Home > Products > Intro” which is absolutely right. But the problem is first level site (i.e. site collection level) where it just displays “Home” for all the pages.
I’ll appreciate any help on this.
Thanks,
Sumit
[...] So one of yesterdays posts brought up a question about rendering the link to the current site. This sort of set me investigating. [...]
Hi Sumit,
No problem, it’s nice to help out.
Well, there are a couple of options for your top level site breadcrumbs, but first - do you _really_ want to do that?
I’ll assume your top level site has the publishing features enabled (if not, the “Pages > default.aspx” thing wouldn’t have been a problem!) That site has a Pages Library called ‘Pages’, and a Page in it with the file name default.aspx then.
As you’ve noticed, if you go to your top level site, you get shown the pages/default.aspx page, and this has a single link back to your top level site on it, which you don’t really want. If you click on that link, it takes you ‘back’ to the page that you’re already at.
However, the Pages Library of your top level site could have other Pages in it, and it does make sense for these to have a breadcrumb link to the pages/default.aspx page. Yes, you could get there through the top navigation bar, but this isn’t as intuitive.
If you’re happy with the information that you’re at the Home page, but you don’t want the ‘Home’ title rendered as a link, you might want to consider your settings on the breadcrumb control for the RenderCurrentLink option. See: http://www.novolocus.com/2008/05/08/breadcrumbs-rendering-the-current-link/
If you really don’t want that text ‘Home’ at all, and it really bugs you, though, there are some options.
The ‘proper’ way of dealing with this would be to write a new SiteMapProvider, install it, add it to your web.config and then use it in your pages. You would have to start from scratch, I suspect - there doesn’t seem to be a CurrentNavSiteMapProviderNoEncode class to subclass (it seems to be part of the PortalSiteMapProvider Class )
(At least, that should be possible - I’ve never tried, but it looks right)
There is an interesting article from Rich Finn which might be useful:
http://blog.richfinn.net/2007/08/14/CustomCMOSSNavigationUsingPortalSiteMapProvider.aspx
Also Shantha Kumar has a list of the Nav providers used in SharePoint, which is pretty interesting.
http://ktskumar.wordpress.com/2008/04/14/sharepoint-navigation-providers-part-1/
Alternatively, the hack approach would be to use some Javascript to get the onetidPageTitleAreaTable, then find the breadcrumb within, then examine how many links there are, and decide whether to set the visibility of the breadcrumb to hidden. But that really does sound like a hack.
[...] of these are really ASP.NET settings rather than most specific. Previously I’ve mentioned using different SiteMapProviders and rendering the current location as a link. Let’s have a look at another couple of [...]