Answered Changing the default masterpage

  • Thursday, August 05, 2010 8:51 AM
     
     

    Hello,

    I want to modify the masterpage so it will use my custom top navigation menu based on an xml file.
    I opened SharePoint Designer and made a copy of v4.master
    In this copy I made my changes, and when using this masterpage my menu displays ok.

    Now I want to apply this masterpage to every site we have within our web application, so every site collection, every (sub)site has to use this custom masterpage.
    Also any new (sub)site that is created in the future should use this custom masterpage by default.

    When I go to the root of my site collection, site settings, I have "master page" under look and feel (after enabling publishing feature on site collection and site).
    There I can set the masterpage that I want to use.
    I've set my custom masterpage for both Site Master Page and System Master Page. I also checked to reset subsites to inherit this setting.
    This seems to work, but not completely:

    1/
    When I click on "all site content" then I still see the old menu by SharePoint, not my own. Same when I go to "site settings", old menu still there. So it seems there it doesn't use my custom masterpage.

    2/
    When I create a new site, and choose to inherit the top navigation from the parent, it will use the old menu from Sharepoint, not my custom menu even the parent uses this. So it seems new sites don't use the custom masterpage I set in the parent.

    3/
    I've done this at the site collection level, is there a way to set it at the web application level so I don't have to go through all site collections to set this custom masterpage ?

    Thanks in advance!

All Replies

  • Thursday, August 05, 2010 9:49 AM
     
     Answered

    1 - all site content uses a different masterpage (you have to change the default system masterpage aswel)

    2 - its a known issue there was a feature for that 2007 (http://masterpagestapler.codeplex.com/)

    3 - you could make a custom feature that does it, or do it with PowerShell, but by default there is no visual interface to do so

    • Marked As Answer by kurtvd Friday, August 06, 2010 9:17 AM
    •  
  • Thursday, August 05, 2010 9:56 AM
     
     

    Hi appie,

    Issue 1:
    I did set the System Master Page to my custom master page as well, but it doesn't make SharePoint use my custom masterpage when I go to "all site content" or "site settings". So this should work normally or did you mean something else ?

    Issue 2:
    OK, so it's not something I'm doing wrong then. We'll see if we can create something similar to automate this or just set it manually each time.

    Issue 3:
    Thanks, I was reading about creating a feature in VS2010 to deploy the masterpage as a site collection feature (and auto enabling it on all sites). I think we'll use this approach to solve this issue.

  • Thursday, August 05, 2010 10:00 AM
     
     

    1 Then something is going wrong :) It might be due to the fact that the all site content uses different ContentPlaceHolders? Can you check the logs (ULS), to make sure there arent any erros?

    2 The link for 2007 is working in 2010 as far as i can see, so you can check that out, or just download the source.

    3 Since its a once in a lifetime action (you only have to do it once i guess), i would suggest PowerShell, think its quicker.

     

  • Thursday, August 05, 2010 11:37 AM
     
     

    I checked ULS but couldn't find anything related to masterpages, but then again I'm not sure what I should be looking for there.

    All I see is timer jobs that get executed, search synchronisation that takes place etc, but no errors or warnings (at least the messages doesn't indicate that).

  • Thursday, August 05, 2010 1:03 PM
     
     
    Are you using the <asp:ContentPlaceHolder id="PlaceHolderTopNavBar" runat="server"> to change your topnavbar?
  • Thursday, August 05, 2010 1:20 PM
     
     

    Yes, I removed SharePoint:AspMenu control and SharePoint:DelegateControl that was in this ContentPlaceHolder, and I've added my jQuery script that fills a div element with the menu based on an XML file.

    But the ContentPlaceHolder with id PlaceHolderTopNavBar is still there (with other content).

  • Thursday, August 05, 2010 1:25 PM
     
      Has Code

    What I have in my custom masterpage:

    <div class="s4-lp s4-toplinks">
    	<asp:ContentPlaceHolder id="PlaceHolderTopNavBar" runat="server">
    			<asp:ContentPlaceHolder id="PlaceHolderHorizontalNav" runat="server">
    			<!-- START: CUSTOM TOP NAVIGATION BAR -->
    			<link rel="stylesheet" type="text/css" href="/resources/top_navigation/style.css" />
    			<script type="text/javascript" src="/resources/top_navigation/jquery.hoverIntent.minified.js"></script>
    			<script type="text/javascript" src="/resources/top_navigation/menu.js"></script>
    			<div id="horizontal_menu"></div>
    			<!-- END: CUSTOM TOP NAVIGATION BAR -->							<br/>       </asp:ContentPlaceHolder>
    	</asp:ContentPlaceHolder>
    </div>
    
    
  • Thursday, August 05, 2010 1:30 PM
     
      Has Code

    Iam not sure but i recall some issue where we had something like the same; what we did was adding the default ASP Menu, and then our custom XMLSiteMap provider, but iam not sure if thats gonna fix your problem, sounds kinda weird, and it should work afaik.

    <SharePoint:AspMenu
    	                 ID="TopNavigationMenu"
    	                 Runat="server"
    	                 DataSourceID="topSiteMap"
    	                 EnableViewState="false"
    	                 AccessKey="<%$Resources:wss,navigation_accesskey%>"
    	                 Orientation="Horizontal"
    	                 StaticDisplayLevels="2"
    	                 MaximumDynamicDisplayLevels="1"
    	                 DynamicHorizontalOffset="0"
    	                 StaticPopoutImageUrl="/_layouts/images/menudark.gif"
    	                 StaticPopoutImageTextFormatString=""
    	                 DynamicHoverStyle-BackColor="#CBE3F0"
    	                 SkipLinkText=""
    	                 StaticSubMenuIndent="0"
    	                 CssClass="ms-topNavContainer">
    		                  <StaticMenuStyle/>
    		                  <StaticMenuItemStyle CssClass="ms-topnav" ItemSpacing="0px"/>
    		                  <StaticSelectedStyle CssClass="ms-topnavselected" />
    		                  <StaticHoverStyle CssClass="ms-topNavHover" />
    		                  <DynamicMenuStyle BackColor="#F2F3F4" BorderColor="#A7B4CE" BorderWidth="1px"/>
    		                  <DynamicMenuItemStyle CssClass="ms-topNavFlyOuts"/>
    		                  <DynamicHoverStyle CssClass="ms-topNavFlyOutsHover"/>
    		                  <DynamicSelectedStyle CssClass="ms-topNavFlyOutsSelected"/>
    	                </SharePoint:AspMenu>
    	              
    	                <SharePoint:DelegateControl ID="DelegateControl6" runat="server" ControlId="TopNavigationDataSource">
    		                <Template_Controls>
    			                <asp:SiteMapDataSource
    			                 ShowStartingNode="False"
    			                 SiteMapProvider="SPNavigationProvider"
    			                 id="topSiteMap"
    			                 runat="server"
    			                 StartingNodeUrl="sid:1002"/>
    		                </Template_Controls>
    	                </SharePoint:DelegateControl>
    
  • Thursday, August 05, 2010 1:38 PM
     
     
    No luck with that.

    I added the AspMenu and DelegateControl back into the page and set the AspMenu to Visible="false".
    Then reset the masterpages (site and system) back to the default, checked to apply to all subsites.
    Then set both again to my custom masterpage, checked to apply to all subsites.

    Opened "all site content", still no change in the menu there. :(
  • Thursday, August 05, 2010 1:39 PM
     
     

    Are other changes visible, (so is only the menu broken), or does it look like the whole masterpage isn't visible, and it uses some default?

  • Thursday, August 05, 2010 1:43 PM
     
     
    Ok, now I'm lost...
    I wanted to see if it actually was using the old masterpage, so I edited the out of the box v4.master and added some text after the menu.
    If I use this masterpage than I can see the text (just to be sure there's nothing placed over it).

    So I set my custom masterpage both on site and system, went to all site content.
    I don't see my custom menu, but the default menu, so I would suspect that it uses v4.master there, but I don't see the text I've added either.

    So I have no clue what masterpage is used there?
  • Thursday, August 05, 2010 1:51 PM
     
     

    Go to: http://url/_catalogs/masterpage/Forms/AllItems.aspx upload your custom masterpage there, and make a copy of the v4.master and change something like the title, then publish both versions as a major one, and make sure there approved.

    Then set the systemmaster as your default or the customized v4.master to check if changes are pushed :-). (I just made a copy of a v4 published it, and it worked, so only thing i can think of is its not being checked in).

     

  • Thursday, August 05, 2010 1:59 PM
     
     

    When I edit the masterpage in SharePoint designer it asks me to check out first, which I do.
    When I'm done editing I save, and right click on the file to check it in.
    Then I choose major version, and I'm prompted that updated files need approval, so I approve the file as well.

    This all happens in the masterpage gallery, so I don't think that doing it through the SharePoint interface will make a difference ?

    But I'll try anyway, you never know for some obscure reason that it will work that way...

  • Thursday, August 05, 2010 2:21 PM
     
     

    Ok tried it, and I noticed that by uploading my masterpage through the SharePoint interface, I need to select what type of file I'm uploading.
    I can choose Publishing Master Page or Page Layout, so I choose Publishing Master Page.

    Then I noticed that when viewing the masterpages in SharePoint Designer the v4.master has "Master Page" as content type, so not "Publishing Master Page".
    I cannot change the content type to "Master Page".

    I noticed that when I copy/paste the v4.master file in SharePoint Designer, no content type will be associated with it. So my first attempt probably didn't have a content type (can't check, I deleted all my changes to start over). And when I upload it through the interface I can only set it to Publishing Master Page, so not the same one as v4.master.

    Could that be the cause ?

  • Thursday, August 05, 2010 2:25 PM
     
     

    When I edit the v4.master directly, then it does work in every possible page I have in my site....

    So I guess I need to find a way to get a custom masterpage in the gallery that uses the Master Page content type to get it working.
    But how do I do that, all I can choose is "Publishing Master Page" and "Page Layout".

  • Thursday, August 05, 2010 2:28 PM
     
     
    By default the Masterpage is a 'hidden' ContentType; thus you cant use it. My best guess is that there are Controls missing in your custom masterpage, and it falls back to the 'default' masterpage. Could you post your code of the masterpage?
  • Thursday, August 05, 2010 2:29 PM
     
     

    Correction, when I copy/paste the v4.master file then it does get a content type associated and it is the "Master Page". Seems like SharePoint Designer has an issue refreshing the gui. When I refresh myself and hover with my mouse over the Content type column the content type is displayed.

    I'll try again tomorrow *sigh* I'm giving up for today.
    I just spent 8 hours of my life (and my boss' time) to create a custom masterpage :(

    I'll let you know if I succeed tomorrow, and thanks already for all the help!

  • Thursday, August 05, 2010 3:09 PM
     
     

    Np, gl with it :)! Let me know what the outcome is :)

  • Friday, August 06, 2010 9:14 AM
     
     Answered Has Code

    Hi appie,

    I tried again today and I think I found where the issue is located.
    I can make a copy of v4.master, and put changes in it.
    When I add some fix text in front of the title, it will be displayed on every page (also "all site content" etc).
    When I add a fix text in front of the menu (AspMenu control) it will displayed on regular pages but not on "all site content". When doing that I added a number to the fix text on the title to see if the masterpage was actually refreshed, and it was the case.

    So it seems that SharePoint treats the ContentPlaceHolders differently on regular pages and special pages like the "all site content" page.

    I continued my quest to see where the difference is located and I finally found out what the issue is here.
    The issue is not the custom masterpage, but the way the menu is placed in the page.

    In the masterpage you have this structure (simplified):

    <div class="s4-lp s4-toplinks">
    	<asp:ContentPlaceHolder id="PlaceHolderTopNavBar" runat="server">
    		<asp:ContentPlaceHolder id="PlaceHolderHorizontalNav" runat="server">
    			<SharePoint:AspMenu ID="TopNavigationMenuV4" ... />
    			<SharePoint:DelegateControl runat="server" ControlId="TopNavigationDataSource" ... />
    		</asp:ContentPlaceHolder>
    	</asp:ContentPlaceHolder>
    </div>
    

    I was expecting that when replacing the AspMenu and DelegateControl with my own menu driven by jQuery it would be OK, but apparently not.
    When I put the text "TEST MENU" in the ContentPlaceHolder "PlaceHolderHorizontalNav", it is not displayed on the "all site content" page.
    When I put the text "TEST MENU" in the ContentPlaceHolder "PlaceHolderTopNavBar", it is not displayed on the "all site content" page.
    When I put the text "TEST MENU" in the div (so not in any of the ContentPlaceHolders), it is displayed on all pages.

    So seems like these two ContentPlaceHolders work differently on the type of page displayed.
    I tried removing them, but then I got an error (since the child pages expect them to be there), so I simply put Visible="False" on the first ContentPlaceHolder and that way the default menu of SharePoint is never displayed and I can put my custom menu in the div, right before the first ContentPlaceHolder.

    Problem solved :D

    Thanks again for all the thinking and trying to solving it! :)

    • Marked As Answer by kurtvd Friday, August 06, 2010 9:14 AM
    •