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”/>
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>
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”/>
SiteMapProvider=”SPContentMapProvider” id=”ContentMap”SkipLinkText=”” RenderCurrentNodeAsLink=”false” NodeStyle-CssClass=”ms-sitemapdirectional” runat=”server”/>
Add following after the control
<script
type=”text/javascript”>
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