Configuring the breadcrumb for pages in _layouts

Search

Accessible SharePoint WebSites
Download ARF

Configuring the breadcrumb for pages in _layouts

http://blog.thekid.me.uk

If you have ever added a page to the _layouts or _admin folders in SharePoint 2007 you may have wondered how to get the breadcrumb to appear at the top of the page. As with many things in MOSS they are using the standard ASP.Net 2.0 navigation features, in particular the sitemap.

To see how it’s done you can simply open the layouts.sitemap (or admin.sitemap) in the ‘_app_bin’ folder of a MOSS IIS site to see how the breadcrumb is built. By editing this file you can ensure your own pages have a breadcrumb and the navigation works.

Now, having done that the chances are that you are going to create a feature so that this page can be used on other sites or farms. Great, you can create a Solution Package and add a file to the LAYOUTS folder which has a specific naming convention – layouts.sitemap.???.xml – where ??? is the name of your feature (has to be unique). This will then get merged into layouts.sitemap when you create a new application.

This is where there appears to be a problem…existing sites will not get updated with your new entries. I have found no way of updating the existing layouts.sitemap (or admin.sitemap) for every server in a farm using the SharePoint API. This problem is compounded by the fact that the sitemap is copied when the IIS site is created and so each IIS site (zone) in a application has to be updated.  

Ideally you could update the layouts.sitemap when your feature gets activated on every server in the farm and for every IIS site within the site collection.

This is where the UpdateLayoutsSitemap class comes in. UpdateLayoutsSitemap gives this functionality by creating a SharePoint job which is executed by OWSTIMER. Updating the layouts.sitemap can be as easy as this…

public override void FeatureActivated(SPFeatureReceiverProperties properties)

{

    SPWeb oWeb = (SPWeb)properties.Feature.Parent;

 

    SPThings.UpdateLayoutsSitemap uls = new UpdateLayoutsSitemap(oWeb.Site.WebApplication);

    uls.AddEntry(“Our Settings”, “/_layouts/oursettings.aspx”, “/_layouts/settings.aspx”);

    uls.AddEntry(“Add New Thing”, “/_layouts/addnewthing.aspx”, “/_layouts/oursettings.aspx?List=1″, “List”);

    uls.SubmitJob();

}

This will cause two new entries to be added to the layouts.sitemap for the specified WebApplication. The second entry will be a child of the first. But wait, if you have gone to the trouble of creating your layouts.sitemap.???.xml file would it not be better to use that? Of course you can…just don’t forget to replace the ??? with your own unique name.

public override void FeatureActivated(SPFeatureReceiverProperties properties)

{

    SPWeb oWeb = (SPWeb)properties.Feature.Parent;

 

    SPThings.UpdateLayoutsSitemap uls = new UpdateLayoutsSitemap(oWeb.Site.WebApplication);

    uls.AddSitemap(“layouts.sitemap.???.xml”);

    uls.SubmitJob();

}

It should also be noted that you can update admin.sitemap as well by adding true to the constructor…

SPThings.UpdateLayoutsSitemap uls = new UpdateLayoutsSitemap(oWeb.Site.WebApplication, true);

UpdateLayoutsSitemap inherits from SPJobDefinition and works by keeping track of the entries and adding them on every server that executes the job. SPJobDefinition is a very helpful class in that it inherits from SPAutoSerializingObject and so can persist all the class members you specify when the job is submitted. This means that when your job executes it is in the same state as when it was submitted. To enable this functionality you need to add an attribute to your class members so that they are persisted

[Persisted]

private System.Collections.Generic.List<string[]> _entries;

If you find it useful feel free to use this class as you see fit.

 

Download UpdateLayoutsSitemap Class File

Posted by Vincent Rothwell on Wednesday, 17 Jan 2007 20:17  - 51 Comments
Orininally printed from http://thekid.me.uk - Copyright Vincent Rothwell 2007
 

Comments

Sunday, 27 Jul 2008 10:36 by ofntlja coabfjpyq
yvmjwbr nedf lcsiewx gjrv xaoqwpkl zgrt jnfiygl

Sunday, 27 Jul 2008 10:36 by
racketeers girlfriend allays disruption depression!denude

Sunday, 27 Jul 2008 10:36 by
configured grid Caltech:temples officio Steven

Sunday, 27 Jul 2008 10:36 by Peru
Nice Site! http://google.com

Sunday, 27 Jul 2008 10:36 by Denny
Hi Vince, Check this out http://dennyonline.wordpress.com/2007/08/14/sharepoint-and-ajax/

Sunday, 27 Jul 2008 10:37 by
Kali subgroups plebeian crept,planting doubtfully cosmology fissure,Titus

Sunday, 27 Jul 2008 10:37 by Scot Hillier
Vince, I have taken your code and used it to create an interface for Central Admin that allows you to manage the layouts site map for any web application. I'd like to post the solution to my codeplex project (www.codeplex.com/features), but wanted to have you review the solution first. Contact me and I'll send you the WSP. Thanks, Scot Hillier

Sunday, 27 Jul 2008 10:37 by Scot Hillier
Vince, I have taken your code and used it to create an interface for Central Admin that allows you to manage the layouts site map for any web application. I'd like to post the solution to my codeplex project (www.codeplex.com/features), but wanted to have you review the solution first. Contact me and I'll send you the WSP. Thanks, Scot Hillier

Wednesday, 30 Jul 2008 12:10 by turkey
thanx docs

Tuesday, 25 Nov 2008 01:02 by rüya tabiri
KEmalcim başarılar güzel kasıyorsun .. Thank youu..

Wednesday, 26 Nov 2008 01:21 by rüya tabiri
Thanks

Wednesday, 26 Nov 2008 01:22 by rüya tabirleri
yanlış ekledik iyimi :D:D:D

Saturday, 3 Jan 2009 01:14 by chat
thank you :)

Sunday, 8 Feb 2009 07:49 by
Thank you

Thursday, 5 Mar 2009 09:01 by sohbet odalari
thank you very much

Saturday, 7 Mar 2009 02:21 by güzel sözler
thank you.. :)

Saturday, 7 Mar 2009 03:16 by Sohbet
thankss

Saturday, 7 Mar 2009 03:18 by Sohbet Odalari
thankss

Saturday, 7 Mar 2009 03:18 by Mirc
thankss youu

Friday, 13 Mar 2009 03:46 by Chat
thank you ..

Saturday, 14 Mar 2009 01:11 by granit
Thank You...

Wednesday, 18 Mar 2009 12:18 by Ligtv izle
thank you cano..

Monday, 23 Mar 2009 06:35 by Mynet
thank you kankamm

Tuesday, 24 Mar 2009 04:59 by Sarki dinle
seoking erkan

Saturday, 28 Mar 2009 05:12 by maç izle
thanki you

Monday, 6 Apr 2009 04:06 by ligtv izle
you are my desire..

Sunday, 12 Apr 2009 12:22 by chat
thank you turkish chat34 !

Saturday, 18 Apr 2009 12:07 by ligtv izle
thank you

Tuesday, 28 Apr 2009 03:25 by chat odaları
thanki

Sunday, 3 May 2009 04:46 by TRsohbet
Thank you

Sunday, 3 May 2009 09:42 by sohbet
thanks

Sunday, 3 May 2009 09:49 by sohbet
thankx

Monday, 4 May 2009 06:26 by justin tv
turkish justin tv..

Monday, 4 May 2009 06:38 by justin tv
turkish justin tv..

Friday, 8 May 2009 05:23 by Sohbet Chat Arkadaşlık
thankss youu

Friday, 8 May 2009 05:25 by FoxChat Sohbet Arkadaşlık
thanks youu

Sunday, 10 May 2009 11:37 by Sohbet
hallo i wish you succes on your job thanks a lot

Friday, 22 May 2009 08:07 by lig tv izle
thanki

Friday, 22 May 2009 08:20 by lig tv izle
thank

Friday, 22 May 2009 07:15 by Edencity Chat
hallo i wish you verry succes operator

Tuesday, 2 Jun 2009 08:12 by Josh
Note that you can force layouts.sitemap to be rebuilt and integrate all new sitemap files by running stsadm -o copyappbincontent. There is also a method somewhere (I think on WebService) called ApplyApplicationContentToLocalServer() which can accomplish this programmatically.

Thursday, 4 Jun 2009 08:54 by Sean McDonough
Vincent, Just wanted to drop you a quick note to say "thanks" for the post. I discovered this as I was making revisions to my own BlobCacheFarmFlush solution (http://blobcachefarmflush.codeplex.com/) to address breadcrumb/sitemap issues in multi-server farm scenarios. Your post helped me with the realization that I wasn't losing my mind (and that the SPWebService.ApplyApplicationLayoutsToLocalServer method is entirely overrated). Thanks!

Wednesday, 8 Jul 2009 09:36 by islami chat
thank you very much my friends..

Wednesday, 8 Jul 2009 09:37 by islami chat
thank you very much my friends..

Saturday, 22 Aug 2009 07:38 by Laptop Tamiri
Thanks good Share

Friday, 9 Oct 2009 07:10 by chat
chat rooms turkish thank you very much..

Saturday, 17 Oct 2009 07:54 by Sohbet
hallo i wish you verry succes operator

Sunday, 22 Nov 2009 09:50 by kaderimsin
thanx docs

Sunday, 22 Nov 2009 10:31 by konya chat
KONYA SOHBET

Thursday, 7 Jan 2010 02:46 by sxe
Nice thanks

Thursday, 7 Jan 2010 02:51 by ÇANAKKALE
çanakkale



Url

Email

Comments