Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm trying to make a site map for a Sharepoint 2010 that will list every site and that site's current nav items. Navigation between sites is done via the top nav. However, I'm having problems getting the current nav items for each site. It appears that each time I get the PortalSiteMapProvider for the web, it returns the provider for the whole site collection. How do I get the items for just that site? I run this code for each site I want to get the items for:

var provider = new PortalSiteMapProvider();
provider.NavigationType = PortalNavigationType.Current;
provider.CurrentWeb = web;
var rootNode = provider.RootNode; 

Anyone have any idea where to go from here?

share|improve this question
add comment

2 Answers 2

So it's not possible to actually run a provider for a given site collection. The PortalSiteMapProvider won't allow it. However, it is possible to put a file in the layouts folder and make it accessible from all site collections. Visit the file from a site collection, and you can enumerate the navigation items for that site collection.

share|improve this answer
add comment

PortalSiteMapProvider can be used only to get navigation settings which is set by a site owner or administrator. It may be possible that some navigation elements(like lists, pages, sites...) are set to hidden by site administrator but they exist in your site collection. So, PortalSiteMapProvider will not give actual nodes for your sitemap.

To generate sitemap, you can programmatically iterate all root sites and use a recursive function to collect navigation information (like title and url) of all child elements (subsites,lists or pages)

By the way, you can see a complete treeview of your site collection from "Site Settings>Look and Feel>Tree view>Enable Tree view"

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.