Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

This is probably a simple thing, but it's not easily googleable with all the discussion of branding/customizing a sharepoint site. I can't find a reliable source on how to set a page to use the "custom" master page. I found this, but it talks about editing your page declaration. I can't do that because the page declaration is part of the wiki page's code. I can't find a way to edit the wiki page, either. I tried to create a new content type (by copying the CreatePage.aspx file and changing its page declaration) in the c:\program files\common...etc directory, but I couldn't find a way to make a page based on it.

What I'm aiming for is most public/anonymous pages to have my branding and the rest of the pages (the "backend" stuff) to use the default v4 master page.

share|improve this question
    
Are you able to use SharePoint Designer 2010? –  spevilgenius Oct 21 '11 at 15:53

4 Answers 4

Under SiteActions -> Site Settings -> MasterPage (under Look and feel) there are two types of master pages

  1. System Master Page - for system pages ( the backend stuff :)
  2. Site Master Page - for public/anonymous pages (Publishing Pages)
share|improve this answer
    
This is MOSS 2010. It sounds like you're describing 2007 maybe? MasterPage isn't under Look and Feel. –  Tim Coker Oct 21 '11 at 14:42
    
It's same for 2010 and 2007 ; have you activated Publishing Feature?? –  Vamsi Oct 21 '11 at 14:45
    
Activate the SharePoint Server Publishing feature both @ Site Collection and Site Level –  Vamsi Oct 21 '11 at 14:47
    
This is Foundation. That's in the full version, right? –  Tim Coker Oct 21 '11 at 14:57
    
You are right!!! –  Vamsi Oct 21 '11 at 16:20

In SharePoint Foundation you don't have the option to set the master page through the browser UI. You can change it either through SharePoint Designer, using PowerShell, or using custom code.

Example using PowerShell:

$web.MasterUrl  = "/_catalogs/masterpage/my.master";
$web.CustomMasterUrl = "/_catalogs/masterpage/v4.master";  
$web.update()
share|improve this answer
1  
+1 I prefer using SharePoint designer because it is easier and doesn't require server access. :) –  Kit Menke Oct 23 '11 at 12:52

In Foundation, it is not possible to change the masterpage for a site using SPD or the UI. You need to do this through code. I usually do this by creating a feature that has 2 properties, oldmaster and newmaster. On Activation, i swap out new for old in the 2 properties SPDoctor mentions, and on deactivate i reverse that action. Here's the code for my Branding feature, that allow you to set a masterpage, a site logo and an alternate CSS file:

using System;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;

namespace DCubed.Framework.Library.FeatureReceivers
{
/// <summary>
/// Represents the feature receiver van de MasterPage Configuration Feature
/// </summary>
[CLSCompliant(false)]
public class BrandingConfigurationReceiver : SPFeatureReceiver
{
    /// <summary>
    /// Represents the property name of feature
    /// </summary>
    public const string MasterPageProperty = "MasterPage";

    /// <summary>
    /// Represents the property name of feature
    /// </summary>
    public const string CssFileProperty = "CssFile";

    /// <summary>
    /// Represents the property name of feature
    /// </summary>
    public const string LogoFileProperty = "LogoFile";

    /// <summary>
    /// Represents the property name of feature
    /// </summary>
    public const string DefaultMasterPageProperty = "DefaultMasterPage";

    /// <summary>
    /// Occurs after a Feature is activated.
    /// </summary>
    /// <param name="properties">An <see cref="T:Microsoft.SharePoint.SPFeatureReceiverProperties"></see> object that represents the properties of the event.</param>
    [SharePointPermission(SecurityAction.LinkDemand, ObjectModel = true)]
    public override void FeatureActivated(SPFeatureReceiverProperties properties)
    {
        if (properties == null)
        {
            throw new ArgumentNullException("properties");
        }

        var web = (SPWeb)properties.Feature.Parent;

        var newMaster = properties.Feature.Properties[MasterPageProperty];
        var oldMaster = properties.Feature.Properties[DefaultMasterPageProperty];

        if (oldMaster != null)
        {
            if (newMaster != null)
            {
                if (web.CustomMasterUrl.Contains(oldMaster.Value))
                {
                    web.CustomMasterUrl = web.CustomMasterUrl.Replace(oldMaster.Value, newMaster.Value);
                }
                if (web.MasterUrl.Contains(oldMaster.Value))
                {
                web.MasterUrl = web.MasterUrl.Replace(oldMaster.Value, newMaster.Value);
                }
            }
        }

        var cssFile = properties.Feature.Properties[CssFileProperty];

        if (cssFile != null)
        {
            // assuming the css file is deployed in the Style Library
            web.AlternateCssUrl = ResourceHelper.GetValue("stylelibraryList", "core", web.Locale.LCID) + "/css/" + cssFile.Value;
        }

        var logoFile = properties.Feature.Properties[LogoFileProperty];

        if (logoFile != null)
        {
            // assuming the logofile is deployed in the Style Library
            web.SiteLogoUrl = "~/" + ResourceHelper.GetValue("stylelibraryList", "core", web.Locale.LCID) + "/gfx/" + logoFile.Value;
        }

        web.Update();
    }

    // rest omitted for brevity...
}

}

ResourceHelper is a custom class that wraps SPUtility.GetLocalizedString. The main method looks like this:

    /// <summary>
    /// Get and returns the value from the Resource Files
    /// </summary>
    /// <param name="key">Identifier to look for in the Resource Files</param>
    /// <param name="file">The resourcefile to look in</param>
    /// <param name="localeId">The Locale LCID of the desired language</param>
    /// <returns>The value returned from the Resource File or Not Found message</returns>
    public static string GetValue(string key, string file, int localeId)
    {
        var retVal = SPUtility.GetLocalizedString(String.Format(CultureInfo.InvariantCulture, "$Resources:{0}", key), file, (uint)localeId);
        return retVal;
    }
share|improve this answer
up vote 0 down vote accepted

What I ended up doing was creating the page, then editing in advanced mode to change the page declaration to use custom.master instead of default.master. This caused the warning that the page had been modified from the site definition, so I just hid the toolbar that generated this message. Not the cleanest solution, but it was the best that I could find.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.