SiteMapPath: Don’t show the root level in breadcrumb
-
How do I customise the behaviour of the asp:SiteMapPath to not show the root siteMapNode as a part of the breadcrumb.
<siteMapNode title="Root"…>
<siteMapNode title="Level_1_1"…>
</siteMapNode>
<siteMapNode title="Level_1_2"…>
<siteMapNode title="Level_2_1"…>
</siteMapNode>
</siteMapNode>
</siteMapNode>Shold in the breadcrumb look like: Level_1_2 > Level_2_1 and not: Root > Level_1_2 > Level_2_1
_____________________________ ...and justice for all
-
How do I customise the behaviour of the asp:SiteMapPath to not show the root siteMapNode as a part of the breadcrumb.
<siteMapNode title="Root"…>
<siteMapNode title="Level_1_1"…>
</siteMapNode>
<siteMapNode title="Level_1_2"…>
<siteMapNode title="Level_2_1"…>
</siteMapNode>
</siteMapNode>
</siteMapNode>Shold in the breadcrumb look like: Level_1_2 > Level_2_1 and not: Root > Level_1_2 > Level_2_1
_____________________________ ...and justice for all
Place the following code in Global.asax:
void Application_Start(object sender, EventArgs e)
{
//
// Register a handler for SiteMap.SiteMapResolve events to hide the
// root node from SiteMapPath controls.
//
SiteMap.SiteMapResolve += new SiteMapResolveEventHandler(HideRootNode);
}static SiteMapNode HideRootNode(Object sender, SiteMapResolveEventArgs e)
{
//
// Hide the root node from SiteMapPath controls by cloning the site
// map from the current node up to the node below the root node and
// setting that node's ParentNode property to null.
//
SiteMapNode node = SiteMap.CurrentNode.Clone();
SiteMapNode current = node;
SiteMapNode root = SiteMap.RootNode;if (current != root) // Just in case the current node \*is\* the root node! { while (node.ParentNode != root) { node.ParentNode = node.ParentNode.Clone(); node = node.ParentNode; } node.ParentNode = null; } return current;
}
-
Place the following code in Global.asax:
void Application_Start(object sender, EventArgs e)
{
//
// Register a handler for SiteMap.SiteMapResolve events to hide the
// root node from SiteMapPath controls.
//
SiteMap.SiteMapResolve += new SiteMapResolveEventHandler(HideRootNode);
}static SiteMapNode HideRootNode(Object sender, SiteMapResolveEventArgs e)
{
//
// Hide the root node from SiteMapPath controls by cloning the site
// map from the current node up to the node below the root node and
// setting that node's ParentNode property to null.
//
SiteMapNode node = SiteMap.CurrentNode.Clone();
SiteMapNode current = node;
SiteMapNode root = SiteMap.RootNode;if (current != root) // Just in case the current node \*is\* the root node! { while (node.ParentNode != root) { node.ParentNode = node.ParentNode.Clone(); node = node.ParentNode; } node.ParentNode = null; } return current;
}
Thanks, This little css-hack also made it for me:
.PageHeading > a:first-child + span + span { display: none; }
_____________________________ ...and justice for all