Search Center and the Lost Search Box

October 14 2010 7 comments

You Have customized your SharePoint site and made a nice design based on the v4.master or even starter.master and applied your custom master as a system master as well. Everything’s cool until your “search-person” configures the search and tells you that something’s wrong with the Search Center. There is no search box at all.

Search Box Ex has gone awol

Search Box Ex has gone awol

Let’s investigate!

Our journey starts from the grassroot level where we travel to the 14-hive and inspect the basic search center’s site definition. We’ll open up the onet.xml found in C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\SiteTemplates\SRCHCENTERLITE\XML\ and look for an instance of the SearchBoxEx webpart in the Default module.

 <Module Name="Default" Url="" Path="">
      <File Url="default.aspx">
                <Property Name="Title" Value="$Resources:Microsoft.Office.Server.Search,SearchCenterPageTitle;" />
                <AllUsersWebPart WebPartZoneID="TopZone" WebPartOrder="1">
                    <![CDATA[
                   <WebPart xmlns="http://schemas.microsoft.com/WebPart/v2">
                       <Assembly>Microsoft.Office.Server.Search, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
                       <TypeName>Microsoft.SharePoint.Portal.WebControls.SearchBoxEx</TypeName>
                       <Title>$Resources:Microsoft.Office.Server.Search,SearchBoxWP_Title;</Title>
                       <Description>$Resources:Microsoft.Office.Server.Search,SearchBoxWP_Desc;</Description>
                       <FrameType>None</FrameType>
                       <AllowMinimize>true</AllowMinimize>
                       <AllowRemove>true</AllowRemove>
                       <IsVisible>true</IsVisible>
                       <Width>800px</Width>
...
...
...

From here we can see that the SearchBoxEx web part resides in a web part zone with an ID of TopZone. Now that we know which web part zone contains the missing search box, we’re going to look it up on the default page layout in C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\SiteTemplates\SRCHCENTERLITE\default.aspx

<asp:Content ContentPlaceHolderID="PlaceHolderTitleBreadcrumb"  runat="server">
<SharePoint:UIVersionedContent UIVersion="3" runat="server">
<ContentTemplate>
<A name="mainContent"></A>
<div style="height:100%; width:100%;padding-left: 18px; padding-top: 50px; padding-bottom: 10px;">
<center>
<div style="width: 390px"  >
</ContentTemplate>
</SharePoint:UIVersionedContent>
<SharePoint:UIVersionedContent UIVersion="4" runat="server">
<ContentTemplate>
<div class="srch-sb-results7">
<div class="srch-sb-results6">
</ContentTemplate>
</SharePoint:UIVersionedContent>
<WebPartPages:WebPartZone runat="server" AllowPersonalization="false" Title="<%$Resources:Microsoft.Office.Server.Search,LayoutPageZone_TopZone

%>"
ID="TopZone" Orientation="Vertical" QuickAdd-GroupNames="Search" QuickAdd-ShowListsAndLibraries="false" />
</div>
<SharePoint:UIVersionedContent UIVersion="3" runat="server">
<ContentTemplate>
</center>
</ContentTemplate>
</SharePoint:UIVersionedContent>
</div>
</asp:Content>

Carefully wrapped inside some legendary HTML lies the TopZone. As you can see from the code snippet above, the TopZone is inside a content control with a very nicely thought ContentPlaceholderID PlaceHolderTitleBreadcrumb. As we know, content placholders reside on the master page and that is the file we are going to look for next. Let’s open up v4.master (I’ll use the one on C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\GLOBAL as I’m a bit lazy but don’t make a habit out of this).

If you do a search for PlaceHolderTitleBreadcrumb on the v4.master you’ll come up with something like this:

<SharePoint:PopoutMenu
runat="server"
ID="GlobalBreadCrumbNavPopout"
IconUrl="/_layouts/images/fgimg.png"
IconAlt="<%$Resources:wss,master_breadcrumbIconAlt%>"
IconOffsetX=0
IconOffsetY=112
IconWidth=16
IconHeight=16
AnchorCss="s4-breadcrumb-anchor"
AnchorOpenCss="s4-breadcrumb-anchor-open"
MenuCss="s4-breadcrumb-menu">
<div class="s4-breadcrumb-top">
    <asp:Label runat="server" CssClass="s4-breadcrumb-header" Text="<%$Resources:wss,master_breadcrumbHeader%>" />
</div>
<asp:ContentPlaceHolder id="PlaceHolderTitleBreadcrumb" runat="server">
    <SharePoint:ListSiteMapPath
        runat="server"
        SiteMapProviders="SPSiteMapProvider,SPContentMapProvider"
        RenderCurrentNodeAsLink="false"
        PathSeparator=""
        CssClass="s4-breadcrumb"
        NodeStyle-CssClass="s4-breadcrumbNode"
        CurrentNodeStyle-CssClass="s4-breadcrumbCurrentNode"
        RootNodeStyle-CssClass="s4-breadcrumbRootNode"
        NodeImageOffsetX=0
        NodeImageOffsetY=353
        NodeImageWidth=16
        NodeImageHeight=16
        NodeImageUrl="/_layouts/images/fgimg.png"
        RTLNodeImageOffsetX=0
        RTLNodeImageOffsetY=376
        RTLNodeImageWidth=16
        RTLNodeImageHeight=16
        RTLNodeImageUrl="/_layouts/images/fgimg.png"
        HideInteriorRootNodes="true"
        SkipLinkText="" />
    </asp:ContentPlaceHolder>
</SharePoint:PopoutMenu>

Wow, the actual content placeholder is inside a breadcrumb popoutmenu. This could be a legacy from MOSS 2007 where the breadcrumb placeholder was close to the main content placeholder in the DOM, but we are not going to support it anymore. Let’s edit here. First we will take the ListSiteMapPath control out of the content placeholder and let the content placeholder tag close itself:

<asp:ContentPlaceHolder id="PlaceHolderTitleBreadcrumb" runat="server" />
<SharePoint:ListSiteMapPath
    runat="server"
    SiteMapProviders="SPSiteMapProvider,SPContentMapProvider"
    RenderCurrentNodeAsLink="false"
    PathSeparator=""
    CssClass="s4-breadcrumb"
    NodeStyle-CssClass="s4-breadcrumbNode"
    CurrentNodeStyle-CssClass="s4-breadcrumbCurrentNode"
    RootNodeStyle-CssClass="s4-breadcrumbRootNode"
    NodeImageOffsetX=0
    NodeImageOffsetY=353
    NodeImageWidth=16
    NodeImageHeight=16
    NodeImageUrl="/_layouts/images/fgimg.png"
    RTLNodeImageOffsetX=0
    RTLNodeImageOffsetY=376
    RTLNodeImageWidth=16
    RTLNodeImageHeight=16
    RTLNodeImageUrl="/_layouts/images/fgimg.png"
    HideInteriorRootNodes="true"
    SkipLinkText="" />

Next we’ll cut and paste the content placeholder next to our main content which is inside a content placeholder PlaceHolderMain:

<div id="MSO_ContentDiv" runat="server">
    <a name="mainContent"></a>
    <asp:ContentPlaceHolder id="PlaceHolderTitleBreadcrumb" runat="server" />
    <asp:ContentPlaceHolder id="PlaceHolderMain" runat="server" />
</div>

And there you have it. The search box is once again visible with your v4-based master.

Edit: John Ross has an alternative opinion on search center customization but it can be hard to convince your clients that search center is something that will not follow your consistent look and feel.

Popularity: 9% [?]

7 comments to “Search Center and the Lost Search Box”

  1. Aapo Talvensaari says:

    Another option is this (better option in my opinion):

    1) Create Normal Enterprise Search Site
    2) Create new Page Layouts for Search Center Pages (look examples from PortalLayouts folder in FEATURES and clean them up, yes ootb layout files are _shit_):
    - layout for default.aspx (the main page)
    - layout for results.aspx (default search page)
    - layout for peopleresults.aspx (people search results)
    (or just use the same layout for all of them!)
    4) Provision new layouts to your site
    5) Change the layouts of the search center pages

    No need to move placeholders anymore. You just use the place holders that you want, the ones you use on all the other pages you have designed. Not the place holders that some idiot wanted to use.

    Basically the search is only a site that has a few pages that have web parts. Well there are some lists and hardcoded controls in ootb search layouts, but you can use them however you want to, or move them around wherever you want.

  2. Aapo Talvensaari says:

    And in case of SRCHCENTERLITE which is not a Publishing Site, you can replace the pages (not the page layouts in this case) just as well. I actually see no reason to use SRCHCENTERLITE if you have enterprise licence. You can remove the hardcoded tabs for example from the enterprise search and make it look exactly like SRCHCENTERLITE.

  3. MSDevGuy says:

    How do we handle the same in Sharepoint 2010 FAST search, searh input box is missing from one of the site collections Search Center

  4. Steve says:

    Thanks man! this post saved me. I got thrown on a project and these scope tabs wouldn’t show up, thanks again :)

  5. Great article – came across the issue and this was a quick fix. Note however, we did have to add a tweak – that was to override the style in the master to hide the left panel (a small box was visible). Open the page then use the F12 debug to get the style name.

  6. Amy says:

    Thanks! I would have never found this on my own. However, if you put the PlaceHolderTitleBreadCrumb above to the PlaceHolderMain content area, the breadcrumb shows up on some pages. I placed it directly after the PlaceHolderGlobalNavigation content area.
    Thanks again for the info!

  7. Franco Caprio says:

    Didn’t came across this issue but I will in the next two weeks. Thank you for the early warning ;)

Leave a Reply