Infosys Microsoft Alliance and Solutions blog

« Creating Multiple Versions of Workflows | Main | Hierarchical Data Categorization using LINQ to Objects in n-tier applications »

Branding in SharePoint Technologies (PART 4)

Today we will look at the option of Site Definitions and Features for modifying the Master Pages.

Site Definitions: As the name suggests, site definitions has all the required information for provisioning a site. There are different site definitions, for different purposes, which are used to provision sites. All site definition files (including the master pages) are stored on the file system; unlike, the site templates that are stored in the content database.
The process to create new site definitions for custom branding is outside the scope of this article. Following is a brief outline of the process:
1.Site definitions are located at <Drive:>\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\SiteTemplates.
2.Copy the desired definition with the name of the custom site definition
3.Change the WEBTEMP XML file with the addition of the configuration node in the templates node for the custom site definition located at the location as shown in Figure 6: Location of the WEbTemp*.xml files. The display category takes care of the tab in which it appears when a person tries to create it through the UI. For more information on the templates and their respective entries, see  http://www.sharepointblogs.com/photos/tbaginski/images/2552/original.aspx.
Note: IIS Reset needs to be done for the changes to get effected and the new site definition to appear during the site creation process.

There are two issues with this approach:
•This requires good understanding of xml files which are used for provisioning the sites. The files include onet.xml and webtemp*.xml files
If OOTB templates are modified then MS technical support will not support them. One needs to be very careful while editing any OOTB site definitions.
•The best alternative is to create a clone of a similar site definition, and edit it to meet the template requirements.
•Sites can be created using any template within a Web Application. This calls for having a one-to-one mapping for all the OOTB templates, in a way to ensure that the end users/administrators use only these templates to create the site. This calls for the discipline during the web application creation. Using OOTB template will result in branding inconsistencies as that will just have the default branding.
 

Features: ‘Features’ is a concept introduced in SharePoint to increase the modularity of the functionality/ elements developed on it. Functionalities like custom workflow, event handlers, copying files, etc can be handled using features. They are highly modular, componentized, can be applied to any site at any level within a Web Application. They can be automatically activated and deactivated.
Using this concept, the master pages for a given site collection is packaged into a feature and applied so that it is copied to the respective gallery and is applied automatically. It is not mandatory to apply the feature automatically. The administrator can apply the master page of choice by browsing through the gallery at any time. A classic OOTB example for this is the ‘SharePoint Server Publishing Infrastructure’ feature which adds master page to the gallery.

Note: Master Pages should be copied to the site collection master page gallery as the SharePoint Look and Feel option in the site settings always refer to this gallery when the admin browses to change the master page

The process to create new function is outside the scope of this article. Following is a brief outline of the process ((The sample will have all the required things so that the end user can customize and start using it) :

1.Create a folder under <Drive>\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES with the name of the feature
2.Place the required .css files, master pages, images required etc in this location
3.Script both the Feature and the elements manifest files
4.Make sure the master pages go to the master page gallery and the other resources go to the style gallery. Sample of this looks like

<Elements xmlns=”http://schemas.microsoft.com/sharepoint/”>
    <Module Name=”CustomMasterPage” Url=”_catalogs/masterpage” RootWebOnly=”TRUE”>      
        <File Url=”CustomPage.master” Type=”GhostableInLibrary” />  
    </Module>
    <Module Name=”CustomStyles” Url=”Style Library” RootWebOnly=”TRUE”>      
        <File Url=”Custom.css” Type=”GhostableInLibrary” />  
        <File Url=”HeaderImage.jpg” Type=”GhostableInLibrary” />  
</Module>
</Elements>

There are different options available both for the module element and the file elements (that is outside the scope of this document).
5.Once this feature is installed using the stsadm utility the master pages and the resource files will become available in their respective gallery.
6.Now this feature can be automatically activated to apply it using another feature called staper feature (The feature discussed above is called the staplee feature). For more information about defining this feature, see http://blogs.msdn.com/sharepoint/archive/2007/03/22/customizing-moss-2007-my-sites-within-the-enterprise.aspx
Note: In addition to deploying the pages into the gallery, features can also be used to deploy the pages into the file system which effectively means that pages can be deployed into site definitions as well.

The following table gives the broad guidance on the scenarios and relevant options.

TrackBack

TrackBack URL for this entry:
http://www.infosysblogs.com/microsoft-mt/mt-tb.fcgi/157

Comments

Hi Prashanth,

It's a fantastic blog. How do I make a custom web part available to everyone's MySite ?

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)