Custom Search MasterPage for SharePoint 2010

I wish I could say that I was smart enough to have figured this one out for myself but I can’t. I was working on my first custom branded SharePoint 2010 site and the search screen was all messed up. The navigation was displaying doubled. It turns out that the search center out of the box used minimal.master. This uses the placeholders that are in v4.master in different way so the search box ends up in the breadcrumb pull down. At any rate, Randy Drisgill wrote a great and very easy to follow post about how to modify your custom masterpage to the search center. It took me longer to create the feature to deploy the new search masterpage than it did to make the modifications.


Update: Randy Drisgill has changed his approach to branding the search screens but here is his original text below.


This is a topic that I’ve been asked probably a hundred times since the SharePoint 2010 bits were released. Before I get into how I solve it, I’ll provide a little back story. To quote from my upcoming book, Professional SharePoint 2010 Branding & UI Design:

There are three site templates to choose from when creating search sites in SharePoint 2010: Enterprise Search Center, Basic Search Center, and FAST Search Center. Unlike most other sites in SharePoint 2010, these sites do not have v4.master or even nightandday
.master applied to them; instead, they have minimal.master applied to them. If you have a custom master page that is based on v4.master, nightandday.master, or even one of the typical starter master pages and apply it to one of these search center sites, you notice that the search center doesn’t work properly. This is because the page layouts and pages that are created by default for these search center sites are hard coded specifically to work best with the way minimal.master is coded.

In fact, if you apply v4.master to one of the Search Centers, the search box seems to be removed from the page… when actually it is still on the page, just hiding up in the pop-out breadcrumb menu:
As you can tell, this is less than ideal. Also problematic is the fact that the default minimal.master that is applied to the search centers doesn’t really contain traditional navigation or ways of navigating back to the parent site. So how do you get custom branding to work with the search center in SharePoint 2010? You have some options:

  1. Create a new custom master page based on minimal.master
  2. Adjust the page layouts or pages in the search center, to use the standard content placeholders (UPDATE: Here is a nice sandbox solution to help do this for you. In many cases this might be the best course of action if you are comfortable using 3rd party solutions: )
  3. Create a new custom master page with some minor adjustments for the way search centers work

For this post, we will focus on the third option. For simplicity, I will walk you through actually converting v4.master to work for the search centers. This can be useful if you want to show the typical SharePoint2010 navigation and UI that is normally hidden for the search center. The concepts here would work just as well with your own custom master page, in fact I have tried it a couple times with my own. Also, I will assume you understand the basics of working with master pages in SharePoint Designer 2010:

  1. Make a copy of v4.master (or whatever other custom master page you are working with) and give it a new name like v4_searchcenter.master.
  2. Edit the new master page and locate and remove the PlaceHolderTitleBreadcrumb. This will allow the pop-out breadcrumb to still function properly:

    <asp:ContentPlaceHolder id=”PlaceHolderTitleBreadcrumb” runat=”server”>
    SkipLinkText=”” />

  3. Next, add the PlaceHolderTitleBreadcrumb back right before the PlaceHolderMain. This will allow the search center to inject the search box in a good location:

    <asp:ContentPlaceHolder id=”PlaceHolderTitleBreadcrumb” runat=”server”></asp:ContentPlaceHolder>
    <asp:ContentPlaceHolder id=”PlaceHolderMain” runat=”server”/>

  4. Move PlaceHolderPageTitleInTitleArea (and any supporting HTML) to a hidden panel because this placeholder isn’t used the same way in the search center:

    <asp:ContentPlaceHolder id=”PlaceHolderPageTitleInTitleArea” runat=”server” />
    <asp:Panel visible=”false” runat=”server”>
    <asp:ContentPlaceHolder id=”PlaceHolderPageTitleInTitleArea” runat=”server” />

  5. For v4.master you will also want to remove ClusteredDirectionalSeparatorArrow and <h2></h2>. It won’t make sense to show these at the top now:

    <SharePoint:ClusteredDirectionalSeparatorArrow runat=”server”/>

  6. Next, several lines of CSS need to be added to make sure things look right for the search center. You can add them to the <head> section of the master page:

    <style type=”text/css”>
    /* remove left margin */
    .s4-ca {
    margin-left: 0px;
    /* remove gray background at top (optional) */
    .srch-sb-results {
    background:transparent none repeat scroll 0 0;
    /* clean up top padding on 1st search page */
    .srch-sb-main {
    padding-top: 20px;
    /* remove centering on 1st search page (optional) */
    .srch-sb-results4 {
    margin: inherit;
    padding-left: 20px;
    /* remove background color on 1st search page (useful for colored designs) */
    .ms-bodyareaframe {
    background-color: transparent;
    /* —————————————— */
    /* — CSS that may be req. to reset the search styling — */
    /* —————————————— */
    /* fix height of area above search results */,, .ms-pagetitleareaframe {
    height: auto !important;
    /* fix border color on search results */
    .ms-main .ms-ptabrx, .ms-main .ms-sctabrx, .ms-main .ms-ptabcn, .ms-main .ms-sctabcn {
    border-color: #eeeeee;
    /* fix arrangement of body area on search results */
    .srch-sb-results {
    height: auto;
    /* fix positioning of prefs and advanced link on results */
    .ms-sblink {
    /* fix the color of the prefs and advanced link on results */
    .ms-sblink a:link, .ms-sblink a:visited, .ms-sblink a:hover {

    5. Save the new master page, and check in / publish as a major version and approve it. Apply this master page to only the search center, and apply it as site master page while leaving system master page set as v4.master.

UPDATE: Some commenters have pointed out that if you want to edit pages in the Search Center (and who doesn’t?) these changes result in a double ribbon scenario. I haven’t fully tested this fix, so I’d be curious to hear about the results, but it looks like this would fix it:

  1. Add <asp:ContentPlaceHolder id=”PlaceHolderGlobalNavigation” runat=”server”/> to the hidden panel.
  2. Remove <div id=”s4-ribboncont”>…</div> and ALL of its contents.
  3. Add in its place this line: <asp:ContentPlaceHolder ID=”SPNavigation” runat=”server”></asp:ContentPlaceHolder>

This should fix the double ribbon issue, but you also LOSE the top popout breadcrumb and the quick edit/save button at the top left of the ribbon.

Here are screenshots of the final result:
You can employ these same techniques on your own master pages to create search center specific branding.

If you had trouble following the code changes you can download the completed v4 search center master page:

Defaulting Preview Pane To First Item in List

A client of ours wanted to use the preview pane for a list view. The default view of the preview pane has the right hand pane blank. You need to select an item or hover an item from the left pane to populate the right pane. The client wanted the right hand pane to have the right hand pane default to first item in the list.

UPDATE 10/21/2013:
It looks like when people are doing a copy and paste of the code that the double quotes ” are getting converted to smart quotes. When you copy and paste make sure that you change any of the single or double quotes to plain text.

UPDATE 9/11/2013:

  • On the list view page (e.g. allitems.aspx) att ?ToolPaneView=2 to the query string. Replace ? with & if there are already properties in the query string.
  • Under the page tab click edit page
  • Add a content editor web part to the page above the list items web part.
  • Click inside the content editor web part where is says add new content.
  • From the ribbon select Edit HTML Source
  • In the resulting pop up window paste the following code.
    <script src=””></script&gt;
    function ()

              $(‘ table tr’).first().trigger(‘onfocus’);

  • Stop editing the page.
  • The preview pane should now default to the first item in the list.

Powershell Commands for Installing Solutions and Features

As a SharePoint 2007 developer I have many of the common stsadm commands committed to memory. While stsadm still works in SharePoint 2010 in favor of moving to proficiency in the latest version of the technology here are some of the powershell commands that I use on a daily basis. With that said, I usually create a batch file that runs these commands so that I only need to run one command to get the features updated and features activated.

Add Solution
Add-SPSolution c:\solutions\myproject.wsp

Deploy Solution
Install-SPSolution –Identity myproject.wsp –WebApplication http://myprojectsite -GACDeployment
Note: You can also use the following parameters

  • –CASPolicies: If you are not deploying to the GAC
  • –AllWebApplications: if you want to deploy the solution to all web applications
  • –Force: to force the deployment of the solution

Upgrade Solution
Update-SPSolution –Identity myproject.wsp –LiteralPath c:\solutions\myproject.wsp –GACDeployment

Retract Solution
Uninstall-SPSolution –Identity myproject.wsp –WebApplication http://myprojectsite

Remove Solution
Remove-SPSolution –Identity myproject.wsp

Activate Feature
Enable-SPFeature –Identity MyFeature –url http://myprojectsite

Deactivate Feature
Disable-SPFeature –Identity MyFeature –url http://myprojectsite

Themes for your SharePoint 2010 environment

I spend most of my time working on custom branding projects using SharePoint. These are great projects and tend to be large custom dev projects. They also tend to have larger budgets. But what about those clients that want a different look and feel but don’t have the large budget. Use a custom theme or template. There are several packaged themes out there for SharePoint 2010 that provide you with a look and feel that while not unique does change the way that SharePoint looks. The themes also provide some level of customization either during the purchase process or after. One of the key things to take into account is that there is probably going to be some level of customization to be done after the fact.

SharePoint Packages: SharePoint Packages offers 5 different SharePoint 2010 themes. I have implimented these for several clients with great results. If you get the platnium package they work with all the OOB SharePoint site templates including MySites. The underlying CSS is not difficult to modify. There are two things to keep in mind with using these themes. Changes made to the theme are not reflected untill you do an IISreset and unapply the theme and reapply the theme to the site so make sure to do all your changes in dev and then put them out on production. The last is that the install process is manuall. You need to copy the files to the 14 hive and import them into the MasterPage gallery. Because of this while it does support branding MySites it is cumbersome for Personal sites. To truly automate this you would need to take all the branding files and include them in a WSP and use feature stapling. Not a big deal but requires a developer to do this.


PixelMill: I was at the SharePoint Conference 2011 and I went to the booth for these folks. It looks like they have interesting products. I have not implimented them yet. They do not support MySites according to their web site. It does look like it is easy to update the CSS after the fact.

SharePoint MasterPages: These people have been around for a while. They have a robust offering of SharePoint 2007 themes and new offerings for 2010. In addition, they also claim that their templates are ready for Office 365 which none of the others point out.

Bind Tuning: This site has several layouts, that feel less like SharePoint, and more like a custom branded site. You also have the ability to use a WYSIWYG editor to customize the OOB to get closer to your individual brand. The site does not list the SharePoint site templates that it supports. I have used these themes and while the price point is great and the customization is excellent it does not support feature stapling so if you want the theme to be applied automatically you will need to create a feature staple feature. The files for this theme do get compiled into a WSP so that does make deployment across the farm easier.

One thing that I like to caution people about when I am recomending a theme is make sure that the theme you choose is close to what you want the end result to look at. It doesn’t make a lot of sense for you to select a theme that uses rounded corners and gradients if you don’t like rounded corners and gradients. It will be lots of pain and angst to try to change a theme that significantly.

Creating SharePoint 2007 Web Part using Visual Studio 2010

One of the things that I love about Visual Studio 2010 is the automated feature and solution creation. This works great when you are developing a web part for SharePoint 2010 and using Visual Studio 2010. Where I ran into a problem was I needed to create a web part for SharePoint 2007. It took me the better part of the day but I managed to get the web part working and deployed to a SharePoint 2007 farm.

I started by creating a blank SharePoint solution in Visual Studio 2010. After that I checked all the references included in the project. These all reference version 14.0 (SharePoint 2010). You will need to delete and add the references again pointing to the version 12.0 dlls. If you don’t have these on your workstation you can copy them from C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\ISAPI on a SharePoint 2007 server and paste them somewhere you will find them easily. I put them in a folder under C:\Users\<username>\Documents\Visual Studio 2010\Projects\dlls.

Open the Package.Package and click the designer. In the properties window look for the SharePoint Product Version number attribute and remove the value.

After this when you use the Visual Web Part template you will need to make a few modifications.
1) Remove the reference to Microsoft.Web.CommandUI.
2) Change all the reference versions from to

Build the project and package the solution. You should now be able to deploy the wsp file normally.

When Pigs Fly…

“Good design is obvious. Great design is transparent.” – Joe Sparano

I have had the good fortune to work with some very talented designers in my career. They have taught me about the difference between good design and great design. The good is something that when you look at it makes you say wow. The great is when you don’t even realize that it was designed well; when something is so intuitive that you instantly know how to find what you are looking for or know how it works. As a web developer it was my job to translate the vision of the designer into SharePoint and make sure that what is great in PhotoShop is great in SharePoint. It is that pixel perfect philosophy that I bring to my work integrating design into SharePoint.

I know that design is generally not the first thing you think about when you think SharePoint. In fact, design is generally the last thing you think about when you think of SharePoint. You think document management, team collaboration, intranets, you think ugly and unusable. By creating a user centric information architecture and implementing compelling visual design SharePoint can be transformed. I am a SharePoint architect at BlueMetal Architects. I have been using SharePoint as a platform for web content management and extranets since 2005. I specialize in applying custom design and brand to SharePoint. I work with clients to architect complex SharePoint solutions from a user perspective.

This blog is about handy development tricks that I use on a regular basis as well as topics of user experience, SharePoint design, and information architecture. At the end of the day I want visitors to the sites I build to say “Wow, that is SharePoint?”