Answered change the masterpage of the search center

  • Friday, January 08, 2010 8:57 AM
     
     
    Hi all,

    I'm testing sharepoint 2010 anf I'm trying to understand if it is possible change the default masterpage of the search center from "minima.master" to "v4.maste"...

    I'm asking this because I don't want to lose the top navigation bar...

    someone has any suggestion??

    thanks all

    Vit

Answers

  • Tuesday, January 12, 2010 8:10 PM
    Moderator
     
     Answered
    Hi Vit,

    This is a bit of a sticky situation. The default master is set to v4.master, but the default site page is built on a layout page which doesn't use the default master. The layout page is assigned the master page by the Microsoft.SharePoint.Publishing.PublishingLayoutPage class, which hardcodes the master page as the custom master. There is a way to work around this and assign a different master page for the page layout, but the end result would probably not work very well.

    Instead of changing the master page, I would suggest adding the top navigation bar to the page layout. This can be done by adding the following code to the SearchMain.aspx Page Layout. Edit it in Advanced Mode. Insert the following code right after this existing code (around line 100):

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

    ADD THIS CODE:
      <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>

    I grabbed the inline styles from corev4.css. You can change those as you please to get your desired look. Also, if you'd rather have all of the pages with minimal.master inlcude the top link, you can add the nop nav to minimal.master instead. Look at v4.master for the placeholder tags that I had to remove for insertion in the page layout. (asp:ContentPlaceHolder id="PlaceHolderTopNavBar" runat="server"> and <asp:ContentPlaceHolder id="PlaceHolderHorizontalNav" runat="server">).


    Hope this helps!
    Kolby
  • Wednesday, January 13, 2010 5:03 PM
     
     Answered

    Sorry if I wasn't clear - you'll have to build a masterpage to work with Search Center, which has different requirements than regular SharePoint sites.  However, custom masterpages other than minimal.master are supported with Search Center, it's just that the OOB masterpages v4.master and default.master will not work correctly with Search Center without customizations.


    Elisabeth Olson SharePoint PM - MSFT

All Replies

  • Tuesday, January 12, 2010 8:10 PM
    Moderator
     
     Answered
    Hi Vit,

    This is a bit of a sticky situation. The default master is set to v4.master, but the default site page is built on a layout page which doesn't use the default master. The layout page is assigned the master page by the Microsoft.SharePoint.Publishing.PublishingLayoutPage class, which hardcodes the master page as the custom master. There is a way to work around this and assign a different master page for the page layout, but the end result would probably not work very well.

    Instead of changing the master page, I would suggest adding the top navigation bar to the page layout. This can be done by adding the following code to the SearchMain.aspx Page Layout. Edit it in Advanced Mode. Insert the following code right after this existing code (around line 100):

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

    ADD THIS CODE:
      <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>

    I grabbed the inline styles from corev4.css. You can change those as you please to get your desired look. Also, if you'd rather have all of the pages with minimal.master inlcude the top link, you can add the nop nav to minimal.master instead. Look at v4.master for the placeholder tags that I had to remove for insertion in the page layout. (asp:ContentPlaceHolder id="PlaceHolderTopNavBar" runat="server"> and <asp:ContentPlaceHolder id="PlaceHolderHorizontalNav" runat="server">).


    Hope this helps!
    Kolby
  • Tuesday, January 12, 2010 8:23 PM
     
     
    If you have search center set up as its own site, you should be able to change the masterpage by going to <search site url>/_layouts/changesitemasterpage.aspx

    From that page, you can change the masterpage to v4.master or anything else you have in the root site MP Gallery (although no guarentees that all masterpages will work with all pages, of course.
    Elisabeth Olson SharePoint PM - MSFT
  • Wednesday, January 13, 2010 8:45 AM
     
     
    Elisabeth,
    It appears that in the case of the search center, other masterpages including v4.master are not supported. You can refer to the following post for more details.

    Vit,
    I just tested Kolby solution and it works well :)
    • Edited by Thibault B. _ Wednesday, January 13, 2010 11:34 AM Removing comment on menu layout which is actually fine
    •  
  • Wednesday, January 13, 2010 5:03 PM
     
     Answered

    Sorry if I wasn't clear - you'll have to build a masterpage to work with Search Center, which has different requirements than regular SharePoint sites.  However, custom masterpages other than minimal.master are supported with Search Center, it's just that the OOB masterpages v4.master and default.master will not work correctly with Search Center without customizations.


    Elisabeth Olson SharePoint PM - MSFT
  • Friday, January 15, 2010 11:14 AM
     
     Proposed Answer Has Code
    Elisabeth,
    Speaking about these different requirements, are there any plans to provide Master Pages with consistent navigation layouts that would make it possible to have for instance a My Site, a Blog and a Search Center site collection with the same menus without having to adapt mysite.master, v4.master and minimal.master?

    Vit,
    If you decide to customize the masterpage instead you can add the code to minimal.master to get the top navigation bar.


    Add this

    <div id="s4-topheader2" class="s4-pr s4-notdlg">
    		<div class="s4-lp s4-toplinks">
    			<asp:ContentPlaceHolder id="PlaceHolderTopNavBar" runat="server">
    				<asp:ContentPlaceHolder id="PlaceHolderHorizontalNav" runat="server">
    					<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>
    				</asp:ContentPlaceHolder>
    			</asp:ContentPlaceHolder>
    		</div>
    	</div>

    before this snippet

    <div>
        <asp:ContentPlaceHolder id="PlaceHolderTitleBreadcrumb" runat="server" />
    </div>
    



    And this line

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

    Before this one

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

    • Proposed As Answer by Thibault B. _ Friday, January 15, 2010 11:16 AM
    •  
  • Thursday, August 12, 2010 6:55 PM
     
     

    Thibault,

    I added the code in my master page, mine is pointing to minimal master page for search center, looks perfect in sharepoint designer 2010, now after saving, i tried to open the search center page,nothing changed. can you please let me know, where i am doing wrong

    Thank you

    Neel

  • Monday, November 08, 2010 8:08 PM
     
     

    Hi Neel0,

    I think you might be doing the same thing I was - editing the minimal.master under the searchcenter site. Most likely your site is inheriting the minimal.master from the "start-site". At least in my case I just had to walk up to the top and change the minimal.master there.

    Hope it helps,

    Henrik

  • Wednesday, December 01, 2010 6:13 PM
     
     

    Hi Colby,

     

    this solution worked as described, thanks although I added the code to the search center default.aspx and also the results.aspx page.  This worked fine and displayed as expected.

    However, when I logged in as a standard domain user with normal visitor (read) rights, the formatting goes and the navigaton top bar links are just added as plain text URLs and are listed one after another vertically, rather than horizontally across the top bar.  Do you know what could cause this effect?

     


    ms
  • Thursday, December 02, 2010 10:07 PM
     
     
    It sounds like your CSS might not be checked in and/or approved.  If you're in one of those cases, users who aren't admins see either the old version of the CSS or no CSS at all if there is no previous approved version.
    Elisabeth Olson SharePoint PM - MSFT
  • Wednesday, January 26, 2011 6:05 PM
     
     Proposed Answer

    Mike,

    How would I get to results.aspx in SP Designer?  All I see under Page Layouts is SearchResults.aspx. 

     

    thanks.

    • Proposed As Answer by combe2 Wednesday, January 26, 2011 6:19 PM
    •  
  • Wednesday, January 26, 2011 6:19 PM
     
     
    Never mind Mike, i figured it out. Thanks anyway.
  • Thursday, February 10, 2011 6:53 PM
     
     

    I have the same issue as MikeSpence with users with visitor/read rights not seeing the formatting correctly. A user with Contribute permissions will see the formatting correctly, and adjusting the "Read" permission level to include "Edit List Items" will also make it display correctly. Strange. This would be a great solution otherwise.

  • Friday, March 11, 2011 12:54 AM
     
     

    Kolby,

    You rule!

    All,

    To clarify, you'll want to insert the snippet in roughly the same spot of the code, as Kolby describes above.  But, the exact line shifts a little on the other pages.  I didn't edit my advanced or people pages, just default, result, and people result.  Here are the insertion points for those.

    SearchMain.aspx line 100

    SearchResults.aspx line 114

    PeopleSearchResults.aspx line 113

    You should see Kolby's "Existing Code" snippet immediately ahead of the lines referenced here.

    UPDATE:  Just past one year later, and my search site got corrupted somehow; had to replace it, and came here to research what I did last year.  Wierd part is those are not the file names anymore, and except for advanced.aspx they all have the parent top nav bar without adding this code.  I'm guessing there must have been some update at some point that I'd not noticed (could be what broke the old one, if that's the case), but no idea really.

  • Tuesday, June 07, 2011 3:03 AM
     
     

    I have the same issue as MikeSpence with users with visitor/read rights not seeing the formatting correctly. A user with Contribute permissions will see the formatting correctly, and adjusting the "Read" permission level to include "Edit List Items" will also make it display correctly. Strange. This would be a great solution otherwise.


    Same problem here. Has anybody found a solution to this?
  • Tuesday, June 07, 2011 3:17 AM
     
     

    Ah, it appears that the corev4.css file is not referenced in the minimal.master page. This is what styles the top navigation and makes it appear horizontal rather than in a bulleted list.

    I simply went and edited the minimal.master and added corev4.css to the other css files it references. Publish and Approve > then you will see your navigation the normal way.

  • Wednesday, June 15, 2011 8:34 PM
     
     

    We followed the suggestions presented here and were successful in adding the top navigation to the minimal.master page in SPD. However, despite approval in the Master Gallery, the search page still shows the original design. Are we missing something that is specific to Office 365?