There are certain nodes in my solution that need to appear in menus/navigation but not appear in the breadcrumbs, as they do not link to actual pages and therefore just present an error when clicked. I've tried several of the techniques pertaining to advanced node visibility from here: https://github.com/maartenba/MvcSiteMapProvider/wiki but I can't seem to get it to work for me. A coworker suggested possibly designing an overload to the SiteMapPath method in the SiteMapPathHelper class, but I'm not sure if this is accurate or how it would be formatted. I'm fairly new to MVC and could really use some help. Thanks!
Thank you @NightOwl888 for your response! I'm going to add a few more details to make sure I'm getting things correct. This is an example of what the section of nodes in the Sitemap file looks like:
<mvcSiteMapNode title="Inventory Management" url="~/Resources/Inventory/Default.aspx">
<mvcSiteMapNode title="Group Inventory" action="#" visibility="SiteMapPathHelper,!*" clickable="false">
<mvcSiteMapNode title="Group Inventory Management" url="~/Resources/Inventory/UnitInventory" controller="GroupInventory" action="Index" />
<mvcSiteMapNode title="Manage All Group Inventory" url="~/Resources/Inventory/ManageAllGroupInventory.aspx">
<mvcSiteMapNode title="Manage Inventory Item" url="~/Resources/Inventory/ManageInventoryItem.aspx" />
</mvcSiteMapNode>
<mvcSiteMapNode title="Search Inventory" url="~/Resources/Inventory/SearchInventory.aspx?module=resource" />
</mvcSiteMapNode>
</mvcSiteMapNode>
"Inventory Management" represents the initial page the user navigates to, where a menu is displayed with the heading "Group Inventory" (the second node), and the menu items are the items below that ("Group Inventory Management", "Manage All Group Inventory", and "Search Inventory"). Each of the menu items are links to other pages, but the menu header is not a link and is not clickable. When I navigate to one of the menu items, the menu header ("Group Inventory") shows up in the breadcrumbs display, even though it doesn't link to anything. So basically if I click on the first menu item, it displays "Home > Inventory Management > Group Inventory > Group Inventory Management", and if the user clicks on "Group Inventory" it results in an error. I need to prevent "Group Inventory" from displaying in just the breadcrumbs trail. I'm struggling a bit to figure this out from your initial response.
P.S. Some of the attributes in the Group Inventory node are ones I added to try to hide it, based on examples I've seen so far.
A
SiteMapNode
is a representation of a real location on your web site or an external site (except for a non-clickable grouping node - that is a node with theClickable
property set to false, which is just for ensuring you still have a hierarchy for a node that doesn't represent a real location).SiteMapNodes
are a server-side representation of nodes - you can think of it like a hierarchial database.If you have additional links you would like added to the menu on the client side (perhaps for some JavaScript functionality), you can customize the menu helper templates in the
/Views/Shared/DisplayTemplates/
directory. If you need to, you can add your own custom attributes to specific nodes to signal your templates exactly where to add your client-side links.See MvcSiteMapProvider hidden mvcSiteMapNode with CRUD operation for more of an idea how to accomplish this.
Related:
On your non-clickable grouping node, you have specified for visibility:
visibility="SiteMapPathHelper,!*"
.Assuming you have setup the default visibility provider as
FilteredSiteMapNodeVisibilityProvider
as per the documentation, you are specifically telling it "make the node visible on the breadcrumb trail, but not anywhere else" (menu, site map, XML site map, etc). So, it is doing exactly what you have specified to do. However, you haven't specified what you are expecting it to do. Perhaps you meant!SiteMapPathHelper
, which means "make the node visible everywhere but the breadcrumb trail"?