SharePoint 2013 Basic Search Center Branding Problem 3

So, I had thought we were in the clear from the old 2010 Search Center branding disaster. For the most part custom branding applies pretty easily to search sites in SharePoint 2013 thanks to the fact that it just uses the default Seattle.master for search branding. However there is a gotcha, specifically related to the Basic Search Center template. I think the problem is only this one template, but maybe there are other areas affected. I tested the Enterprise Search Center and the default search and neither had issues.

Basically what happens is when you are creating your custom branding, chances are you will be applying a customized master page (one that is edited with a mapped drive or SharePoint Designer), and the Basic Search Center uses a snippet of code block to try to hide the ribbon when the Web Part management panel is up (I have no idea why this was so important but I digress). Okay, “so what” you might think… well code blocks are not permitted to run by default in customized master pages. They will work just fine in a custom master page deployed with a farm solution (according to comments below a sandbox solution will not fix the problem) but they will fail miserably in a customized master page like this:

4-27-2013 4-05-07 PM

So, how do you fix this problem. Well, easiest solution is to package your custom master page into a farm solution and apply it to the site. The error should go away immediately. That doesn’t really help if you are still iterating in development or if you are using SharePoint Online (farm solutions are not allowed there). Another option is to edit the aspx files on the Basic Search Site. From a mapped drive or from SPD you can edit default.aspx and results.aspx removing this StyleBlock section:

<asp:Content ContentPlaceHolderId="PlaceHolderAdditionalPageHead" runat="server">
  <SharePoint:StyleBlock runat="server"> 
    WebPartManager webPartManager = SPWebPartManager.GetCurrentWebPartManager(this.Page);
    if (webPartManager != null && webPartManager.DisplayMode == SPWebPartManager.BrowseDisplayMode)
    display: none;

Note: one gotcha you may run into with this method is sometimes the search web parts will error on the page when you refresh it. You can fix this by removing the old web parts and re-adding them. I’m not sure why you have to do this sometimes, but it’s a relatively painless fix.

For some of you, editing these search files won’t be an acceptable solution. I’m hopeful someone will create a nice sandbox solution to fix the problem like we had in 2010… Nik Hadlee I’m looking at you 🙂

3 thoughts on “SharePoint 2013 Basic Search Center Branding Problem

  1. Reply Tom Daly May 29,2013 11:55 pm

    I’m blown away at how this doesn’t work as expected, but I can’t say I’m not surprised b/c it’s SharePoint. In my case I’m having different results than you.

    I’ve deployed a slightly modify seattle.master called test.master via Visual Studio to the Style Library for my branding solution and that did not work on the Basic Search Center. I checked w/ SPD and it’s not customized. (this should have worked?)

    I then replaced my custom master page with seattle.master and renamed it to copy.master and that did not work on the Basic Search Center. Again it’s shows in SPD as not customized. (this probably should have worked too?)

    In SharePoint Designer I copied and pasted seattle.master -> copy.master and applied that, which works fine. But as soon as you edit it and it no longer works.

  2. Reply Tom Daly May 30,2013 9:11 am

    In my previous post I meant – deploying to Master Gallery, not Style Library.

    Anyhow – a sandbox/online deployment via Visual Studio will never work. You have no option but to open the Basic Search Center – default.aspx page and remove that code snippet.

    For me this also broke the search box webpart, but I simply edited the page delete and add a new one.

  3. Reply Kevin Caron Sep 25,2017 1:17 pm

    You just saved my day! Thanks!

    And yeah both web parts had errors for me too, I had to replace the old ones.

Leave a Reply