Unanswered customized master pages

  • Monday, August 15, 2011 4:27 AM
     
     
    We usually create a site collection in the sharepoint, open up the site in sharepoint designer the navigate to the master pages and edit the master page. I usually prefer to use the Starter 2010 Master Pages by Randy Drisgill. Is there anyway that I can produce the starter master pages as soon as the site is created ? To make it more clear, when I create a site in sharepoint what I need is the new site to use the starter master page instead of the v4.master which is currently used as default master page. The advantage being, I don't have to open the sharepoint designer, make a copy of of v4.master, copy and replace it contents by the content of starter master pages. Is that possible ? Any ideas would be great!

All Replies

  • Monday, August 15, 2011 5:06 AM
     
     

    Hi

    You can create a custom site defintion or a web template to achieve this.

    Create a site and apply  your custom master page. Save it as a template. This will create a wsp file.

    If you want to create subsites in the same site collection this should be enough.

    But if you want to create site collections using this template you have to go through a few more steps

    You have to import the solution in VS2010 and deploy it at the farm level.

    I have a full walk through in my blog. Please check it out.

    http://doitwithsharepoint.blogspot.com/2011/08/create-site-collections-from-web.html

    You can also create custom site definition by copying the existing site templates in the 14/TEmplates/Site Templates folder.

    You have to modify the onet.xml and another XML file called WebTemp.xml to register the custom site defintion.

    Check these for a start.

    http://msdn.microsoft.com/en-us/library/ms454677.aspx

    http://www.ahmadkhalaf.com/ahmadkhalaf/blog/?p=113

     

     

  • Wednesday, August 17, 2011 1:56 AM
     
     

    sorry for the late response!

    The save as site template works if it is a team site but what I am working on is a publishing site.

     

    Is there any ways to make the publishing site work the same way ?


    Appu
  • Friday, April 13, 2012 2:36 PM
     
     

    No, you can't save as site template on a publishing site. Do check out the following discussion: http://social.msdn.microsoft.com/Forums/is/sharepoint2010general/thread/77be725d-cd9d-4ead-9445-74999b63d5bf

    Btw, it's an old thread, so I'm not posting this for the benefit of the original asker, but for future readers...


    Kind regards,
    Margriet Bruggeman

    Lois & Clark IT Services
    web site: http://www.loisandclark.eu
    blog: http://www.sharepointdragons.com


  • Tuesday, April 17, 2012 4:08 AM
     
      Has Code

    There's a couple different ways you could accomplish this.
     
    1. VS2010 - Create a feature that deploys the masterpage to your site and apply it.

    2. PowerShell - Create a script that will upload the masterpage to the site and then apply it.

    If you use powershell, make sure you check in and publish the masterpage in your script (since it's a publishing site). 

    # Get the custom MP
    $customMP = get-childItem "path to masterPage"
    $curWeb = get-spweb "url to SP Site"
    # We're uploading the custom master page to the master page gallery.
    $spfolder = $curWeb.getfolder("_catalogs\masterpage")
    $SPFileCollection = $spfolder.files
    $SpFileCollection.Add("_catalogs\masterpage/"+$customMP.Name,$customMP.OpenRead(),$true)
    # Find our newly uploaded MP so we can Checkin, Publish, and approve it (Since it is a publishing site)
    $mpFile = $curWeb.lists["Master Page Gallery"].items |Where {$_.Name -eq $customMP.Name}
    $mpFile.file.CheckIn("checkin comment") 
    $mpFile.file.Publish("publish comment")
    $mpFile.file.Approve("Approve Comment")
    #Apply the MP to our site
    $curWeb.CustomMasterUrl = $web.ServerRelativeUrl + "/" + $mpFile.url 
    $curWeb.MasterUrl = $web.ServerRelativeUrl + "/" + $mpFile.url 
    #commit the change  
    $curWeb.Update() 

    • Edited by Jared Asbury Tuesday, April 17, 2012 9:20 PM Updated script
    •