Creating Sharepoint/MOSS sitemap -


text after "itemprop =" text ">

I'm trying to create a sitemap for my MOSS publishing site, I've got two approaches but stuck with Both are happening.

My first approach is the use of PortalSiteMapProvider, which has already been created and well cached ...

  PublishingWeb rootWeb = PublishingWeb.GetPublishingWeb (SPContext) .Current.Site .RootWeb); // Get the default page URL in the web string default PageUrl = rootWeb.DefaultPage.ServerRelativeUrl; PortalListItemSiteMapNode Webnode = (PortalListItemSiteMapNode) PortalSiteMapProvider.CurrentNavSiteMapProviderNoEncode.FindSiteMapNode (defaultPageUrl); HttpContext.Current.Response.Output.WriteLine ("top level:" + webNode.Title.ToString () + '

But this site seems to back up everything in collections (such as lists, surverys). I only want to show SharePoint webs

My second method was to use this piece of code.

  SPSite siteCollection = new SPS ite ("http: // example .org "); SPWebCollection sites = Siteclose AllWebs; Foreign exchange (SPEVOB site in sites) {console. Videline (site title.tostring) + "+ site.ServerRelative url.tostring ());}  

In addition to the problem of returning all the webs in a flat list, which is correct.

Ideally, I want to add indentation to show child trail.

PortalSiteMapProvider is pre-coded for you and can tear through a whole site structure in milliseconds.

About SPSite.AllWebs , that's The property does return a flat list of all the webs about your question, this is what it is for if you want only a instant child list for the list, then SPSite.RootWeb.Webs Use the property in each SP web in the Webbase property Callers, and their web site call to get tree view.

Also, while working with the object model, make sure Dispose of each web and site if you do not, then this epic will be the cause of bad problems. It also includes disposal of every web in the website collection, even if you have not touched it.

Edit:

To return PortalSiteMapProvider to only the webs, include property to false .


Comments