Farrukh Subhani
Farrukh Subhani

Reputation: 2038

Using Visibility (Default) attribute in MVCSitemap to show nodes only in breadcrumbs

Anyone who has achieved a single xml file but different menu and breadcrumbs with MVCSiteMapProvider package.

I have MVC.Sitemap all working well with my menu and breadcrumbs. I have added a new node for Home - Products This is Index Action on Products Controller I dont want this to appear in my menu but I do want it to appear in my Breadcrumbs when someone lands on /myapp/Products/Index or Products/Index

At the moment I am using visibility="SiteMapPathHelper,!*" picked up from the example and I am assuming the latest nuget package and my web.config is setup with

attributesToIgnore="visibility"

which is confusing as i dont understand that does this mean to ignore the parameters or does it tell that nodes that need to be ignored are filled with this parameter and value should be taken as condition.

Upvotes: 1

Views: 806

Answers (1)

Wayne Brantley
Wayne Brantley

Reputation: 694

By default, any attribute MvcSiteMapProvider sees in your menu XML declaration is added to the url parameter.

So, if you have this:

<mvcSiteMapNode area="Admin" controller="User" action="Index" title="Users" someRandomAttribute=3/>

the sitemap will use

/admin/user/index?someRandomAttribute=3 for the url.

If you put attributesToIgnore="someRandomAttribute" in the config, the url it will generate will become:

/admin/user/index

The visibility provider is a plug-in system - and the default one uses a 'visibility' attribute so it can decide if the node is visible or not.

Upvotes: 2

Related Questions