Friday, July 18, 2014

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:
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>

Reference:

No comments:

Post a Comment

Image noise comparison methods

 1. using reference image technique     - peak_signal_noise_ratio (PSNR)     - SSI 2. non-reference image technique     - BRISQUE python pac...