This article provides a template for adding the breadcrumb to the top of your custom settings pages. If you are unfamiliar with the steps involved to create a custom settings page and have it show up in the links in the Site Collection Administrators section on the Site Settings page, first check out these posts:

Using the SPPropertyBag with Custom Admin Pages in SharePoint by Steve Gragert

Office Space: Custom Auditing In SharePoint by Ted Pattison

Using the techniques described in the above-mentioned articles I was able to setup a custom settings page and access it from the Site Settings page:

SiteCollectionAdminLink

However once loaded I noticed there was no breadcrumb displayed above the new page title:

SiteSettingsNoBreadcrumb

The reason the breadcrumb does not appear is because SharePoint does not have the custom settings page in it’s sitemap file which exists on disk “somewhere” in the 12 hive. Furthermore, SharePoint does not provide a programmatic means to add the page to the sitemap by updating a feature configuration or writing code that uses the object model. The only way to add your page to the sitemap is to physically update the sitemap file on every server in the farm. And as every good SharePoint student learns early on, we should not modify files on disk because they might change in future upgrades and it makes farm deployment across multiple servers more time-consuming and error prone due to the need to update every server manually.

After a couple of days working on this admin page it was quite aggravating not having the breadcrumb since that is what I always use to get back to the main Site Settings page. So here’s what I did: using Firebug I found the html generated by admin.master when it builds the breadcrumb and then added that to my page by overriding the content section populated in the master page. Since the custom settings page will always be deployed at the Site Collection level, the only item I had to populate dynamically was the Site Collection title. The custom settings page title can simply be added in the ASPX for the page:

SiteSettingsBreadcrumb

Here’s the code template to add to your custom settings ASPX page. Substitute “SETTINGS PAGE TITLE” below with your custom settings page title:



    
    
        
     > 
    
        
    
     > 
    SETTINGS PAGE TITLE



Add the variable and text assignment for SiteRootLink to the code-behind for your custom settings page as shown below. The code snippet assumes the custom page inherits from Microsoft.SharePoint.WebControls.LayoutsPageBase:

protected HyperLink SiteRootLink;

protected void Page_Load(object sender, EventArgs e)
{
    this.SiteRootLink.Text = this.Site.RootWeb.Title;

Admittedly this is not the most robust of solutions because it’s possible Microsoft may change the style definitions or controls used to generate the PlaceholderTitleBreadcrumb. I do think it’s one step better then having to modify the sitemap file on all the servers in a farm due to the inconvenience and the equally likely chance a future upgrade might change the location or structure of the sitemap file. So it’s not ideal, but at least it’s something that can be packaged into a feature and deployed without the need for manual changes after feature deployment.

Bookmark and Share  Comments [0] | Permalink | SharePoint

Leave a Comment

Name (required)
Email (will not be published)
Website
 

Comment Preview
Subscribe
Top 5 Posts
Add Google Analytics to a SharePoint Publishing Site
Integrating jQuery 1.3, ASP.NET 3.5 Visual Studio 2008
Add Custom Table Formats to SharePoint Content Editor
Configuring log4net for SharePoint Windows Authentication
Convert Visual Studio 2008 Class Library Project to Web Application Project
Tags
ASP.NET (5) dasBlog (5) GoogleAnalytics (2) jQuery (1) log4net (2) SharePoint (18) WebDesign (3)
 
 
 
Spreadfirefox Affiliate Button
 
Download Notepad++