SharePoint: Remove Page node from breadcrumb

Scenario:

We were using breadcrumb and wanted to remove “Pages” library link from breadcrumb.

Resolution:

The control we were using was:

<asp:SiteMapPath
SiteMapProvider=”SPContentMapProvider” id=”ContentMap” SkipLinkText=”” RenderCurrentNodeAsLink=”false”
NodeStyle-CssClass=”ms-sitemapdirectional” runat=”server”/>

One way of removing the “Pages” node is to use “CurrentNavSiteMapProviderNoEncode” instead of “SPContentMapProvider”. Also, make sure that you have checked “Show Pages” under “Site Settings -> Navigation ->Current Navigation”.

This approach has one drawback that if you are using OOTB Left Navigation, then, pages will also start appearing in the “Left Navigation”. In order to avoid this, we are left with jQuery. Below is the snippet to accomplish above.

First include jQuery in your page:

<script
src=”http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js”></script>

Add you control as:

<asp:SiteMapPath
SiteMapProvider=”SPContentMapProvider” id=”ContentMap” SkipLinkText=”” RenderCurrentNodeAsLink=”false” 
NodeStyle-CssClass=”ms-sitemapdirectional” runat=”server”/>

Add following after the control

<script
type=”text/javascript”>

$(“Span[id=’ctl00_ContentMap’]”).children().each(function(){

if($(this).text()==’Pages’)

{

$(this).next().remove();

$(this).remove();

}

</script>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: