how to add a new page to the site that does not show up on the navigation bar

Topics: Developer Forum, User Forum
Feb 9, 2009 at 7:51 PM

I am trying to figure out how to add a new page to the site that does not show up on the navigation bar?

To explain further, I want to have 25+ such pages that would get linked from a high level page.  I just don’t want them to show on the navigation menu because they would flow off the bottom of the page. 

These pages are fully public accessible.

Feb 9, 2009 at 11:58 PM
Edited Feb 11, 2009 at 3:13 PM
It's a fairly easy change to do this.  It involves a few steps.  You just need to add a new attribute in your web.sitemap.  MWPSK has already done this with the visible="[true/false]" attribute.  Open up your web.config in App_Data to take a look.

The processing logic for it to be hidden from the navigation bar happens in App_Code\CustomXmlSitemapProvider.cs.  Take a look at it and it should be pretty easy to infer how to extend it a little.

Once you have that done, just modify your administration page to allow you to read and write this attribute and you should be set.

If you aren't able to get it, post how far you've gotten and I'll help you out with source code.  I haven't done it yet, but it's something on my to-do list.

Good luck! 
Feb 11, 2009 at 1:53 AM

Ok, this might be a little over my head.  So with this update would I still be able to toggle on-off this visible feature?  I only want some pages to not show up on the navigation menu.

Also are you talking about the "WebSite.config" file in the App_Data folder?

Thanks for the help

Feb 11, 2009 at 3:13 PM
Exactly.  Updating it would maintain and extend existing functionality.  And sorry, I totally misspoke.  It's actually the web.sitemap that drives the navigation.  I'm at my workstation now and it's a little more involved than I thought.  The framework uses the CustomXmlSitemapProvider class to both secure access to pages and to hide pages from the navigation bar.  It's pretty tightly coupled, so changing that may have unintended effects.  I looked around for someone who has done the same thing and I found this:

The author has made his source code available directly from the site.  It is based on the MWSPK framework, and has some pretty neat extensions.  I'll outline the changes the author made.  Any credit goes to the author. 

App_Data\web.sitemap has a new attribute: VisibleInMenu.
The author wrote a customer XML Sitemap DataSource class in App_Code\Providers\CustomSiteMapDataSource.cs to provide the sitemap controls with only visible nodes.
New menu control: UserControls\TopMenu.ascx - the important thing to note here is that his sitemap datasource ctonrol is of type CustomSiteMapDataSource.  The logic in the codebehind seems redundant unless I'm missing something.

Anyway, hope that gives you a start.

Feb 15, 2009 at 2:25 AM
Thanks so much for digging this up.
Looks real close to what I need!!