As you can see I have tried setting a property of Hidden but this seems to have no effect. Is there any way to set the page to be created in the site but not shown int he navigation. I have relatively limited experience with site definitions so am probably approaching it wrong?

UPDATE: I decided to approach this a different way and "simply" hide the navigation item in a feature event receiver run when the site is provisioned. However this turns out to be far from simple.

At first I tried to access the Navigation of the SPWeb

((SPWeb)properties.Feature.Parent).Navigation.TopNavigationBar;

But this is a null reference. So I created a PublishingWeb from the web and looked in there

But this is also a null reference. Some searching on Google turned up this article - http://blog.mastykarz.nl/programmatically-configuring-menu-items-sharepoint-2010/ - which explains that the navigation is not populated until it is first updated through the UI and provides a fairly low level powershell solution to populate this navigation by creating a fake SPContext, grabbing a PortalSiteMapProvider and getting the navigation from there. I rewrote this into my feature receiver and have code looking like this:

Alas the nodes collection is empty. I have tried using the GlobalNavSiteMapProvider and the CombinedNavSiteMapProvider with the same results. However when the receiver finishes the site does indeed have navigation items.

This seems like such a basic requirement that nearly every SharePoint development would need; some deployable control of navigation.

Is this really the way we are supposed to do this? Is there not a simple solution? And if it is the recommended way does anybody know why the nodes collections are always empty for me?

What is the purpose of your page? Does it have to be in a page library? Can the page be customized by some privileged users?
–
Steve BJul 2 '12 at 13:50

It is in effect, although a simplification, a 'results' page, however the results are displayed by a web part and there is other content on the page which can be customized by content editors, administrators etc. The page should only be reached by 'searching' as without context it is useless, but is a publishing page with workflow for content updates too.
–
robwilliamsJul 3 '12 at 8:45

2 Answers
2

Provision the file not to a doc library but to a folder (or even to the root folder of the site, where default.aspx lives). It will be all but invisible from the web interface(unless you create a nav link), however it will be visible to site admins via SharePoint Designer(if they know where to look).

The site, or at least the web containing the page in question, is public internet and the page should be accessible to anonymous users. However we naturally want anonymous access restricted to a limited number of lists/libraries. If I put the page in a folder, won't this mean that I can't make it accessible to anonymous users? What I really want is a solution to adding it to a library, but without adding it to the navigation.
–
robwilliamsJul 3 '12 at 9:09

After revisiting this problem several times and wasting much time on trying to find a resolution I have resorted to a small piece of custom Javascript which updates the menu on page load to hide and add items as required.