Kieran
Kieran

Reputation: 18059

Can I use more than one master page on a sharepoint site?

I have been asked to modify a home page to a completely new design, all other pages will remain exactly the same.

I am a little green when it comes to sharepoint. I have created the masterpage, however when i choose set as default master page or set as customer masterpage it changes for the entire site. I would only like to change the home page.

The only option I have come across at this point would seem to be Detach from page layout which would not be ideal as the remainder of the site may be pushed into this new skin

Upvotes: 4

Views: 2960

Answers (3)

DHJ
DHJ

Reputation: 31

From your description, it sounds like you need a new page layout and not a master page.

Master page is typically used for navigation, footer, and similar outer layouts and affects all pages. Page layout is used for specific designs and when you create a new page you can use it as template, starting point for a specific layout and typically displays your contents

Upvotes: 1

Tjassens
Tjassens

Reputation: 922

Programmatically changing the masterpage for this particular page is the only option as nigel says.

You can create a custom page layout for the homepage and then set the masterpage on the pre-init as shown below:

public class MyPageLayout:PublishingLayoutPage 
{ 
    protected override void OnPreInit(EventArgs e) 
    { 
        base.OnPreInit(e); 
        this.MasterPageFile = "~/_catalogs/masterpage/mynewmasterpage.master";                    
    } 
} 

Upvotes: 4

Nigel Whatling
Nigel Whatling

Reputation: 2391

SharePoint Publishing pages inherit from the Microsoft.SharePoint.Publishing.PublishingLayoutPage class, which sets the master page programmatically to the site defined custom master page. There is no way to override this behaviour other than to do so through code yourself.

Upvotes: 3

Related Questions