Search is a fundamental component of any SharePoint solution and 2010 has some subtle differences and great improvements over its 2007 predecessor:
- One improvement are refiners, a new part of the search user interface (formerly known as facets), which allow you refine the search results based on metadata and even better they are extensible
- One important difference between 2007 and 2010 is the use of a specific master page in the Search Centres – the minimal.master master page
I’m not a big fan of minimal.master used within the Enterprise Search Centre so that’s the focus of the rest of this post. I’ll propose a way to deliver a fix which basically boils down to not using the minimal.master.
So what’s the problem with minimal.master? Minimal.master is a cut down master page that is new to SharePoint 2010 and used by both Enterprise Search and Office Web Apps. As the Search master page it lacks a few key components available in the other SharePoint 2010 master pages. One fundamental component that is missing in minimal.master are navigation controls.
The minimal.master lacks most of the usual navigation controls you expect and need.
V4.master has the standard top navigation and the new 2010 breadcrumb (hidden inside the folder “up” icon)
Missing the main navigation leaves an Enterprise Search Centre completely isolated from the rest of your SharePoint solution. This is a big limitation – is there are any situation where you shouldn’t be able to get from your search results back to the main and/or other sites?
So why don’t we just change the search master page to one of those other fully featured ones like V4.master? Yeah that was my first idea too. And look what we get…
An Enterprise Search Centre with v4.master applied “floats” the search controls into the breadcrumb navigation.
That wasn’t the result I was expecting and I guess it wasn’t the result most people were expecting if they tried this? This is not a bug but one of those “by design” problems. What you’re seeing is the way the four page layouts of Enterprise Search have been implemented to work specifically with the placeholders in the minimal.master master page. Personally I think this was a poor implementation decision because it uses some of the core placeholders completely differently than the other OOTB SharePoint master pages. Compare V4.master and minimal.master:
Place Holder | Use in Minimal.master for search | Use in V4.master for…most other things |
TitleInBreadCrumb | Search controls | Breadcrumb navigation controls |
SPNavigation | Empty in the master page. The search page layouts add page editing controls and the ribbon instead. | Page editing controls and the ribbon |
The Current Approaches to using a Custom Master Page with Search
We have two options if we want to get rid of the minimal.master from search and put back some of the things we have lost:
- Create a custom search master page that is compatible with the search page layouts; or
- Modify the search page layouts to make them compatible with an existing custom master page
If you want to do the first option and create a custom master page for search then Randy Drisgill has a really useful and detailed post on how to convert a V4.master (normal) master page to work with the Search Centre.
The second alternative solution is to modify the page layouts to work with your existing custom master page. I first came across the idea via Chris O’Connor and prefer this approach. It’s biggest benefit is you only have to develop/test/maintain one master page which can be used on all your SharePoint sites including the search site!
Unfortunately there is at least one negative side effect to modifying the search page layouts – it makes them unghosted (customized). Unghosted files are generally frowned upon in SharePointland so this approach won’t always suit everyone’s environment/requirements. The biggest problem, and a very valid reason to dislike unghosted files, is once they are customized a copy lives in the content database that is disconnected from the original file system version. This means:
- These page layouts will not be updated by any changes to the file system versions such as solution (wsp) upgrades and service packs
- There is a performance penalty (I don’t know how much?) because of the extra database hit required to retrieve the page layout from the content database
Fix Option 2. Explained
There are a few changes that have to be made to all of the search page layouts and your custom master page to implement fix option number 2. To make this as clean as possible I have packaged the changes into a sandbox solution and use a site collection feature (feature activation receiver) to perform all of the heavy lifting in the page layouts:
- Change the target placeholder that is used by the search controls by replacing the Id from TitleInBreadCrumb to a custom placeholder ID CustomSearchControls
- Remove the SPNavigation placeholder and all its content from the page layouts. This content placeholder is in the v4 master page already so it’s just a duplicate and causes weird ribbon “jumping”
- Add some CSS style rules to hide the left navigation areas of the page because search doesn’t use this area of the page
A big benefit of doing all that work in a feature receiver is the changes are all reverted and the page layouts are reghosted/uncustomized if the feature is deactivated.
Last point – there are changes that must be made to your custom master page to support these modified page layouts. If you don’t add the following placeholder you’ll get an error. The screen shot below shows what needs to be added (the wrapping <div> isn’t strictly necessary but it allows for any custom styling that might also be needed).
![]() |
And once you upload the sandbox solution to the solution gallery, activate the solution/feature and switch your master page to one with the custom placeholder this is what you will see:
This is a good place to stop. The files are up on codeplex and I hope to do a follow up post soon that explains the source code in detail. If you have any ideas on how to improve this or just general comments please hit me up via a blog comment or on twitter. For now here are links to the files:
- Sandbox solution with a site collection feature to do the page layout fix-up described in the post – Search.CustomMasterPageAdapter.wsp
- Source code of the feature receiver – PageLayoutFixup.cs
- Example custom master page which is just v4.master with the custom place holder added – Custom.v4.master