Breadcrumb Path Separator and Path Direction

There are several settings you can apply to breadcrumbs in MOSS, although really some 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 settings:

Examples of various breadcrumb settings and different SiteMapProvider's output

(Yes, this screenshot shows some other settings – they’re mentioned in the other articles)

Looking at the screenshot we can see how the Path Separator setting allows us to set what we want shown between nodes – rather than ” > ” I’ve used “:”. Not sure when/why you’d want to change that, but I’m sure I’ll be given a design where that is useful sometime!

There’s also the Path Direction setting, which allows us to set whether the breadcrumb should have the current node on the left or right of the breadcrumb – hence the two settings, RootToCurrent and CurrentToRoot. Note, though, that the default path separator doesn’t swap from ” > ” to ” < “.

Breadcrumb Path Separator and Path Direction

Breadcrumbs – Rendering the current link

So one of yesterdays posts brought up a question about rendering the link to the current site. This sort of set me investigating.

There are a number of settings you can use with the ASP:SiteMapPath control. One is the RenderCurrentLink option. This defines whether the current location indicator in the breadcrumb should be shown as a link.

Examples of various breadcrumb settings and different SiteMapProvider's output

(Yes, this screenshot shows other settings – I’ll discuss them in other posts)

Looking at the top 4 rows you can see the effect of the the RenderCurrentLink option – it determines whether the last item is displayed as a link or not.

Breadcrumbs – Rendering the current link

My Breadcrumbs have "> Pages > default.aspx" in them

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"/>


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.

My Breadcrumbs have "> Pages > default.aspx" in them

Are SharePoint Breadcrumbs completely wrong?

I upgraded the version of WordPress I’m running recently and I enabled statistics on the blog. It’s been a bit of an eye-opener. My posts on ‘What the heck is going on with SharePoint Breadcrumbs‘ and ‘More SharePoint Breadcrumbs WTF‘ have together more hits that any of my other articles, and both are visited about evenly.

This is pretty interesting. Breadcrumbs should be pretty simple. I mean, we all use them on the web, probably every day, and often without noticing. So how come people are clearly looking up information about SharePoint breadcrumbs? Clearly something is wrong with them.

So this set me thinking – what’s wrong with them? And here’s what I could think of:

  • There are two breadcrumbs. You’ve got the Global breadcrumb, and then the PlaceholderTitle breadcrumb. Seriously, how many websites do you come across that have two?
    Image showing the Global and Title Breadcrumbs
  • ‘Site’ levels of the hierarchy can appear in one or the other breadcrumb. Depending on whether or not your navigation inherits it’s navigation from it’s parent site, the ‘Site’ links can appear in the global or title breadcrumbs. Thus, there’s no consistency as to where a site appears – if it appears at all! I can see why it’s been built this way – essentially it allows us to ‘skip’ levels in the site hierarchy as shown on the global breadcrumb, and it shortens the title breadcrumb. I wonder if this wouldn’t be better facilitated by a ‘show in Global breadcrumb’ site setting. Or just show all sites in the path to the site?
  • Why is what is shown in the breadcrumbs tied to what is shown in the site’s top navigation? That’s just confusing.
  • Having some breadcrumbs in the Page Layout (i.e. in the main content area) and others coming from the master page is just plain confusing.

I don’t quite know what the answer to this is; after all, we need a way to navigate back up the site hierarchy, though we might not always want to allow that. And breadcrumbs could get very long, so yes, maybe we want to skip levels. But I think I’d be tempted by showing all sites in the Global navigation. This would also divorce the breadcrumb from the top navigation settings, and I think would be easier.

And if the Global navigation gets too long? Well, that seems quite possible. In that case, how about a setting on each site to ‘Display in Menu in the Breadcrumb’ to give something like this:

Concept of single breadcrumb using drop down menus

This way you can still have your ‘Main’ sites in the hierarchy, but all levels are still available. Of course, you might want to make it that all the subsites of last ‘Main’ site are always visible irrespective of that setting. I think that would work, and would require less getting used to.

It’s a bit like the Vista breadcrumb in Windows Explorer – but a bit different, which might count against it…

The breadcrumb in Windows Explorer in Vista

That said, I’m open to thoughts from others! Comment if you’ve got an idea of how breadcrumbs should work!

Are SharePoint Breadcrumbs completely wrong?

Web Part for showing subsites

This is kind of obvious, but why isn’t there a web part for showing subsites?

Sure, there is the ‘Table of Contents’ web part, but annoyingly that shows other things in the site, like lists and libraries, rather than just child sites. And there isn’t any setting I can find on it to make it behave that way – which also seems a pretty obvious feature. So annoying – 90% there, but not quite.

Well Chis Johnson has has the same though and made an example. I’m not entirely convinced about creating the output string in the property (that’s a bit bizarre Chris), but it’s a good start.

I guess it’s another bit of a gripe about out-of-box navigation in SharePoint

Web Part for showing subsites

Folder based Navigation in SharePoint

We have a customer who wants a fairly simple site – all it needs to be is a heirarchy of web pages.

Unfortunately, SharePoint Publishing features don’t really do this very well. Yes, in a document library it does breadcrumbs as you navigate through folders – but you can’t really do that with Pages. For a start, you can’t put folders in pages libraries!

So, instead, they’ve got this deep structure of sites – just to get the navigation. The site permissions and features are the same at all levels. This is a real administrative pain – especially if want to change the definition of the content types used in the pages libraries throughout the site.

What would be better would be to have navigation providers which show Folders in the navigation – so that they’re exposed in the left navigation (and maybe the top – I’m not sure). You could then enable folders in your page library. Users would then be able to navigate down through folders and pages. I guess there is a question as to which page should be the ‘default’ for a folder (obviously the folder itself isn’t a page that can be shown) – but perhaps something like just having a convention that the page ‘default’ is shown would be enough. Or maybe make it part of the metadata for a ‘Publishing Folder’ content type.
This would mean that the whole deep heirarchy and dozens of sites my customer is using could be dealt with in one single site. I can’t quite believe that nobody had this idea when they were planning the WCM features for MOSS. I don’t even think it’d be that hard – I just hope that I get a chance to implement this sometime…

Folder based Navigation in SharePoint

You can do a lot with page layouts…

I’ve been blogging a fair bit lately about Page Layouts – how they affect styles to hide bits of the page, how they are used to replace breadcrumbs and the like – but you can do a heck of a lot with them.

Quite a lot of your default master page is in ContentPlaceHolder controls. Those ContentPlaceHolder controls have default content – but your page layout can define Content controls which place content into those placeholders, overriding them. Of course, you still need to have all of the appropriate controls on a page – just removing the ‘Site Actions’ menu for everyone isn’t a good idea – but you can do a lot.

This sort of came up at the last SharePoint User Group meeting – Colin Byrne was demonstrating Silverlight in SharePoint (which apparently doesn’t work all that well yet, but shows promise). One of the demos he has showed replacing the left navigation with a Silverlight control, but used a neww Master Page do to that. I thought of a demo I’d done recently where I’d done similar – but with a Page Layout. I used this to replace the left navigation menu with a Web Part Zone:

Normal View

Page Extensively Modified by a Page Layout

Edit View

Page Extensively Modified by a Page Layout - Edit View

Believe it or not, this is actually the default master with a particular Page Layout that I made, and the ‘Simple’ theme applied. Actually, there are lots of bits of the page modified by the Page Layout. The ‘Site Actions’ menu and Top Navigation Bar have been moved up, for example. The Left navigation has been replaced by a Web Part Zone, and I’ve dropped a Content Query Web Part in there for a giggle. And the Search box has been moved down the page too.

You could do all of this with a Master Page of course – and in real life, you’d probably want to for most of those modifications. For some things, though, like replacing certain navigation controls (which is what some of the out-of-box page layouts do with title breadcrumbs) then I think that a page layout might be exactly what you want – so that you can have different forms of navigation for different pages using the same Master Page.

Anyway, I was surprised by how easy it was to do this. Given that the Master Page defines default content, much of what I did was just copy that default content into the Content control for the location that I wanted to put the control into – and voila!

You can do a lot with page layouts…

Page Layouts, Breadcrumbs, and the space above the main content area of a page.

Previously, I’ve blogged about some of my investigations into how breadcrumbs work in SharePoint – and how sometimes they’re shown in the ‘Page Title Area’, and sometimes they’re put into the ‘Main Content Area’.

One of our customers was building a page layout, and wanted the breadcrumbs inside the Main content area. They put the following content controls into the page layout file:

<%-- This content tag blanks the 'title' placeholder, which is above the white 'main content area' of a page --%>
<asp:Content ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea" runat="server" />

<%-- This content tag blanks the 'title breadcrumbs' placeholder, which is above the white 'main content area' of a page --%>
<asp:Content ContentPlaceHolderId="PlaceHolderTitleBreadcrumb" runat="server"/>

<%-- This is the main content for a page. This content tag is an example only.
Usually there is more formatting and web part zones, other controls, etc.--%>

<asp:Content ContentPlaceHolderID="PlaceHolderMain" runat="server">

<!-- This tag defines the breadcrumb to display. On a normal page (such as defaultlayout.aspx) it is a contained within a table -->
<asp:SiteMapPath ID="ContentMap" Runat="server" SiteMapProvider="CurrentNavSiteMapProviderNoEncode" RenderCurrentNodeAsLink="false" SkipLinkText="" NodeStyle-CssClass="ms-sitemapdirectional"/>

<!-- This tag displays the text of the page's 'Title' that is given when it is created. -->
<SharePoint:FieldValue id="PageTitle" FieldName="Title" runat="server"/>


Unfortunately, this resulted in a gap between the top of the page content area, and the bottom of the top navigation:

Page Layout Gap

So, what was missing?

Well, it turns out that another couple of content controls are relevant:

<asp:Content ContentPlaceHolderId="PlaceHolderPageImage" runat="server"><IMG src="/_layouts/images/blank.gif" width=1 height=1 alt=""></asp:Content>

<asp:Content ContentPlaceHolderId="PlaceHolderAdditionalPageHead" runat="server">
<style>, .ms-pagetitleareaframe {
height: 10px;
} {
height: 100%;
.ms-pagetitleareaframe table {
background: none;
height: 10px;

The first content tag blanks the ‘page icon’ placeholder, which is above and to the left the white ‘main content area’ of a page. It is set to show a 1 pixel transparent image, and it appears that this is to maintain page structure, where setting the content to nothing might allow the table cell to collapse. And I thought that 1 pixel transparent gifs were so 1992.

The second content tag reduces the space available for the ‘page title area’ through CSS. It overrides some of the styles to do this. Of course, this relies on your master page using those styles, or having that structure – so if you’re planning on creating a custom master page, you’d better think of all custom page layouts too. I’m not really convinced about that as design – it seems to me that this makes creating a new, radically different master page even harder, as the page layouts must be rebuilt too.

Page Layouts, Breadcrumbs, and the space above the main content area of a page.

More SharePoint Breadcrumb WTF

Previously I’d posted about SharePoint Breadcrumbs and how they were confusing as hell. I’d discussed how SharePoint publishing pages override the ‘PlaceHolderTitleBreadcrumb’ content control, filling it with blankness, and then supplying their own breadcrumb as part of the page content. That seemed pretty dumb to me… …much more sensible would be to override the ‘PlaceHolderTitleBreadcrumb’ with the breadcrumb we want.

Well, it transpires that I was wrong. What I’ve described is true for some page layouts… and not for others. The Default Master page defines its PlaceHolderTitleBreadcrumb ContentPlaceHolder control as:

<asp:ContentPlaceHolder id="PlaceHolderTitleBreadcrumb" runat="server">
<asp:SiteMapPath SiteMapProvider="SPContentMapProvider" id="ContentMap" SkipLinkText="" NodeStyle-CssClass="ms-sitemapdirectional" runat="server"/>

This is defining the default breadcrumb on the master page.

For the DefaultLayout.aspx layout page, it defines the content for the page to have:

<asp:Content ContentPlaceHolderId="PlaceHolderTitleBreadcrumb" runat="server"/>

That will empty the placeholder on the master page, so no breadcrumb will appear in the usual location – in fact, nothing will. (Note: you will probably want to reduce the blank space that the breadcrumb occupied – otherwise you’ll have a bit gap above your main content area). It then goes on to define (in the PlaceHolderMain Content control):

<td class="ms-pagebreadcrumb" colspan="2">
<asp:SiteMapPath ID="ContentMap" Runat="server" SiteMapProvider="CurrentNavSiteMapProviderNoEncode" RenderCurrentNodeAsLink="false" SkipLinkText="" NodeStyle-CssClass="ms-sitemapdirectional"/></td>

There we can see the breadcrumb that appears in the page content.

However, if we look at a different page layout, such as BlankWebPartPage.aspx, we see:

<asp:Content ContentPlaceHolderId="PlaceHolderTitleBreadcrumb" runat="server">

<div class="breadcrumb">
<asp:SiteMapPath ID="siteMapPath" Runat="server" SiteMapProvider="CurrentNavSiteMapProviderNoEncode" RenderCurrentNodeAsLink="false" SkipLinkText="" CurrentNodeStyle-CssClass="breadcrumbCurrent" NodeStyle-CssClass="ms-sitemapdirectional"/>



Okay, interesting. So, what’s different about the breadcrumbs? Well, a few things, but the point relevant to whether or not the “> Pages > default.aspx” is displayed in the breadcrumbs – 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’.

It is a bit mystifying why some page layouts blank the PlaceHolderTitleBreadcrumb while other override it – it would have been really nice if they worked consistently. And, as a side note, if you create a page layout and find that your breadcrumbs include the “> Pages > default.aspx” bit, then 1) make sure you’re providing content to override the PlaceHolderTitleBreadcrumb, and 2) make sure that it uses the CurrentNavSiteMapProviderNoEncode navigation provider.

More SharePoint Breadcrumb WTF

What the heck is going on with SharePoint Breadcrumbs?

Like many web applications, SharePoint uses ‘Breadcrumbs’ for navigation. This is a set of links that both tell you where in a hierarchy you are, and were you can go to. SharePoint, though, uses two:


You can see them here at the top left, and then above the word ‘Documents’. But wait, the master page shows us two breadcrumbs? You’re only in one hierarchy, so how does that work? The Planning & Architecture documentation on Technet says:

The default.master master page, which displays form and view pages, includes two breadcrumb controls, a global breadcrumb which contains sites only, and a content breadcrumb, which contains sites and the current page. Some collaboration site templates, such as the Team Site template, also include two breadcrumbs on all Web pages

However, this isn’t quite the complete story. Continue reading “What the heck is going on with SharePoint Breadcrumbs?”

What the heck is going on with SharePoint Breadcrumbs?