I am using the ASP.NET MVC SiteMap provider in a project, and it is working great. I am having a tough time trying to figure out how to hide a menu item however. The menu item I want to hide from displaying in the global navigation is my "Site Map" page. Now I know that there is something called a VisibilityProvider
available to me on the mvcSiteMapNode - but I can't seem to figure out how to make it work.
First, I suggest you read this wiki page: Creating a Custom SiteMapNodeVisibilityProvider. Then for the specific node that points to your Site Map page, declare it this way:
<mvcSiteMapNode title="Site Map" controller="Home" action="Map" visibility="false" />
Now, when implementing the IsVisible
method (shown in the wiki page linked above), you can do this:
string visibility = mvcNode["visibility"];
// Is a visibility attribute specified?
if (!string.IsNullOrEmpty(visibility))
{
isVisible = Convert.ToBoolean(mvcNode["visibility"]);
if (!isVisible)
{
return false;
}
}
return true;