Showing posts with label SharePoint customization. Show all posts
Showing posts with label SharePoint customization. Show all posts

Saturday, October 6, 2012

Finding what site definition is used by a SharePoint site

If you're performing SharePoint migration, you might face an issue with custom site definitions (or templates) site are based on. Or you might want to know what out of the bow definition was used for a site.

To find the template there are different options:
  1. Using SharePoint Manager tool [available for 2007, 2010 and 2013.] Download it for free from Codeplex and install it. Then open the SharePoint Manager and connect to the SharePoint site collection. When you click on a specific SharePoint site, on the right side it will show you all the properties available in the SP object model for that site. Find WebTemplate and Configuration values for the site:
  2. If there is no way to install SharePoint Manager or if any other problems, then save the current site as site template [.STP or .WSP extension]. And save it to disk somewhere. Navigate to that location and rename the file to .CAB extension. Extract the CAB file.If it is SharePoint 2007 you will find manifest.xml file that contains TemplateID and Configuration of the site:

    If it's SharePoint 2010 open the folder that ends with "
    WebTemplate" and open Elements.xml. Find BaseTemplateName and BaseConfigurationID in the file:



     Navigate to end of this post for the TemplateID to Name mapping.
  3. Through managed code we can identify this very easily with the below code:

    view plaincopy to clipboardprint?
    using (SPWeb web = site.OpenWeb("/"))
    {    
       string templateID = web.WebTemplateId.ToString();
    }
  4. Using STSADM.EXE. It needs high level permissions. Means the user should be an administrator on the server. Below is the command we need to use for knowing the site template.
    stsadm.exe -o enumallwebs -databasename [content database name]
  5. Using SQL Management Studio you can execute the below query on the content database of the site collection.
    SELECT Title, WebTemplate, ProvisionConfig FROM dbo.Webs WHERE Title='Test Publishing Site'

Choose one option which is useful or easy for you and identify the correct template.


Site template ID to Name mapping:
0 - GLOBAL (SetupPath=global) - "Global template"
1 - STS - "windows SharePoint Services Site", STS#0 - "Team Site", STS#1 - "Blank Site", STS#2 - "Document Workspace"
2 - MPS - MPS#0 - "Basic Meeting Workspace", MPS#1 - "Blank Meeting Workspace", MPS#2 - "Decision Meeting Workspace", MPS#3 - "Social Meeting Workspace",  MPS#4 "Multipage Meeting Workspace"
3 - CENTRALADMIN - "Central Admin Site"
4 - WIKI - "Wiki Site"
7 - BDR - "Document Center"
9 - BLOG - "Blog"
20 - SPS (OBSOLETE) - "SharePoint Portal Server Site"
21 - SPSPERS - "SharePoint Portal Server Personal Space"
22 - SPSMSITE - "Personalization Site"
30 - SPSTOC (OBSOLETE) - "Contents area Template"
31 - SPSTOPIC (OBSOLETE) - "Topic area template"
32 - SPSNEWS (OBSOLETE) - "News area template"
33 - SPSNHOME (SubWebOnly) - "News Home template"
34 - SPSSITES - "Site Directory area template"
36 - SPSCOMMU (OBSOLETE) - "Community area template"
38 - SPSREPORTCENTER - "Report Center Site"
39 - CMSPUBLISHING (SubWebOnly) - "Publishing and Team Collaboration Site"
40 - OSRV  - "Shared Services Administration Site"
47 - SPSPORTAL - "Corporate Intranet Site"
50 - SRCHCEN - "Search Center"
51 - PROFILES - "Profiles"
52 - BLANKINTERNETCONTAINER - "Internet Presence Web Site"
53 - BLANKINTERNET (SubWebOnly)BLANKINTERNET#0 - "Publishing Site", BLANKINTERNET #1 - "Press Releases Site", BLANKINTERNET#2 - "Publishing Site with Workflow"
54 - SPSMSITEHOST - "My Site Host"
56 - ENTWIKI - "Enterprise Wiki"
90 - SRCHCENTERLITE (SetupPath=SiteTemplates\SRCHCENTERLITE) - "Search Center Lite"
6221 - PWA (SetupPath=SiteTemplates\PWA) - "Project Web Access Site"
6215 - PWS (SetupPath=SiteTemplates\PWS) - "Project Workspace"
14483 - OFFILE - "Records Repository", "Records Repository"


Tuesday, October 2, 2012

SharePoint site templates vs site definitions.

Site Template
  • A site template (*.stp file) is created through the user interface or through implementation of the object model. It is a package containing a set of differences and changes from a base site definition.
  • The site template package is stored as a CAB-based file that can be downloaded or uploaded to site collections by users with the appropriate rights. As before, site templates offer a measure of portability to SharePoint Applications.
  • It is not as fast as a pure site definition as site definitions are cached on start of IIS on the web front ends while site templates are stored and hence need to be fetched from the content database and merged with the site definition code at runtime to render the site.
  • Also note that if you plan to transfer a site template to separate farm, that the farms have the same versions installed of SharePoint installed.  (hotfixes,etc.) This is due to the dependence site templates have on the original base site definition they were created from.
Site Definition
  • The core definition of what a site is in SharePoint.
  • It is installed on file system of web front ends, located at ..\12\Template\SiteTemplates. This directory is language-neutral.
  • It consists of .aspx pages and .xml files with Collaborative Application Mark-up Language (CAML).
  • A major benefit is that the Page and List definition is read locally from the file system, not from Content Database.
  • A site definition Page and List definition are cached at the IIS process start up
  • Customizations made to site definition are stored in content database, not on the file system. This can be performed via SharePoint Designer, or when custom site templates are saved.
  • Site Definitions are developer created
  • Localization: WSS 3.0 supports full site template localization (based on ASP.Net 2.0 via XML files and .ASPX files pulling strings from RESX files. Therefore solutions can be shipped “language packs” of resource files.
  • “Global Template” defines commonality across site definitions; it gets called before any other template. It works by injecting common provisioning content into all new sites. ONET.XML file defines base types, galleries, mobile redirects
  • Data is stored directly on the Web servers, so performance is typically better.
  • A higher level of list customization is possible through direct editing of a Schema.xml file.
  • Certain kinds of customization to sites or lists require use of site definitions, such as introducing new file types, defining view styles, or modifying the Edit menu.
  • Customization of site definition requires more effort than creating custom templates.
  • Editing a site definition after it has been deployed is difficult.
  • Doing anything other than adding code can break existing sites.
  • Users cannot apply a SharePoint theme through a site definition.
  • Users cannot create two lists of the same type with different default content.
  • Customizing site definitions requires access to the file system of the front-end Web server.
  • Custom templates are easy to create.
  • Almost anything that can be done in the user interface can be preserved in the template.
  • Custom templates can be modified without affecting existing sites that have been created from the templates.
  • Custom templates are easy to deploy.
  • Custom templates are not created in a development environment.
  • Custom templates are less efficient in large-scale environments.
  • If the site definition on which the custom template is based does not exist on the front-end server or servers, the custom template does not work.

Custom site definitions hold the following advantages over custom templates:

  • Data is stored directly on the Web servers, so performance is typically better.
  • A higher level of list customization is possible through direct editing of a Schema.xml file.
  • Certain kinds of customization to sites or lists require use of site definitions, such as introducing new file types, defining view styles, or modifying the Edit menu.


Site definition disadvantages include the following:

  • Customization of site definition requires more effort than creating custom templates.
  • Editing a site definition after it has been deployed is difficult.
  • Doing anything other than adding code can break existing sites.
  • Users cannot apply a SharePoint theme through a site definition.
  • Users cannot create two lists of the same type with different default content.
  • Customizing site definitions requires access to the file system of the front-end Web server.


Custom templates hold the following advantages over customization of site definitions:

  • Custom templates are easy to create.
  • Almost anything that can be done in the user interface can be preserved in the template.
  • Custom templates can be modified without affecting existing sites that have been created from the templates.
  • Custom templates are easy to deploy.


Custom template disadvantages include the following:

  • Custom templates are not created in a development environment.
  • Custom templates are less efficient in large-scale environments.
  • If the site definition on which the custom template is based does not exist on the front-end server or servers, the custom template does not work.