May 03, 2012

Add Top Navigation Bar to SharePoint Search Center

By default the top navigation bar is not included in Search Center.  This TechNet Forum discussion explains it well.  I'm not a coder and I don't want to lose this information so I've summarized it here.  I don't know exactly what all of it does, but I can guess at it.

Using SharePoint Designer to edit the Search Center site, check-out the page layout SearchMain.aspx, edit it in advanced mode, find this section of code shortly after the ContentPlaceHolderID="PlaceHolderTitleBreadcrumb" (creating a backup copy is recommended)... again not a coder so I don't know the correct terminology:

</ContentTemplate>
</SharePoint:UIVersionedContent>
<SharePoint:UIVersionedContent UIVersion="4" runat="server">
<ContentTemplate>


Then add this code (mine was at line 100):

<div class="s4-lp s4-toplinks" style="background-image:url(/_layouts/images/selbg.png); background-repeat:no-repeat;
repeat-x:left top; background-color:#f6f6f6; vertical-align:middle; min-height:25px; border-top:1px solid #e0e0e0;
border-bottom:1px solid #b8babd">
    <SharePoint:AspMenu
    ID="TopNavigationMenuV4"
    Runat="server"
    EnableViewState="false"
    DataSourceID="topSiteMap"
    AccessKey="<%$Resources:wss,navigation_accesskey%>"
    UseSimpleRendering="true"
    UseSeparateCss="false"
    Orientation="Horizontal"
    StaticDisplayLevels="2"
    MaximumDynamicDisplayLevels="1"
    SkipLinkText=""
    CssClass="s4-tn"/>
    <SharePoint:DelegateControl runat="server" ControlId="TopNavigationDataSource" Id="topNavigationDelegate">
       <Template_Controls>
          <asp:SiteMapDataSource
          ShowStartingNode="False"
          SiteMapProvider="SPNavigationProvider"
          id="topSiteMap"
          runat="server"
          StartingNodeUrl="sid:1002"/>
       </Template_Controls>
    </SharePoint:DelegateControl>
</div>


Save the file and check it back in.  If Source Control is enabled, you'll need to approve the changes before they're visible to everyone.  This goes for the file modifications below as well.

Now, because these changes are referencing the corev4.css file and the minimal.master page does not include a reference to that I need to include that css file in the minimal.master.  Again, I'm not a coder so there might be a cleaner way to do this!

Edit, save, check-in, and approve the Master Page minimal.master to add this line where the other css are referenced (mine was line 22):

<SharePoint:CssRegistration Name="corev4.css" runat="server"/>

This will fix the default page.  The same code as far above needs to be done to SearchResults.aspx (my line 114).  Haven't found the place to add it in Advanced Search yet.