Friday, November 4, 2011

Different ways to identify what template is used for the site for SharePoint sites

I have receives several requests from different people who what to know the site template that was used to create their sites. Since there are several different options to get site template information and each one may be better under certain condition. Sometimes, you will get the site template ID instead name. You could refer here to relate the ID to name.

Here is the summary of the options and you could chose based on your situation.

1.  View site home page source code - Easiest way for end users
Login to the site. Click browser's View menu and source the source code. Search the variable g_wsaSiteTemplateId and the value associated. The example for a “Team Site” is:

         <script type="text/javascript">
         //<![CDATA[
        
         var g_wsaLCID = 1033;
         var g_wsaSiteTemplateId = 'SPS#0';
        

2.  View saved site template configuration – Another accurate way for end users
Save the site as template. Get the saved site template (ex. Test.wsp) from Solutions Galleries and saved to local drive. Rename the .wsp to .rar file. Then you could browse to folder TestWebTemplate and open file Elements.xml. Search BaseTemplateName value. Example for a “Blank Site” is:

            <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
               <WebTemplate AdjustHijriDays="0" AlternateCssUrl="" AlternateHeader="" 
               BaseTemplateID="53" BaseTemplateName="BLANKINTERNET" BaseConfigurationID="0"
/>
            </Elements>

3.       View WebTemplateId property from SharePoint Manager tool – easy way for system admin or developer who have access to the server
Download the SharePoint Manager tool and open the site. Browse to view WebTemplateId property. Example for a “Team Site” is:


4.       Command to display the site template IDs and site map status for all site collections and subsites – easy for system admin to get for all sites
STSADM -o enumallwebs
Example is:

  <Database SiteCount="1" Name="WSS_Content_3333" DataSource="SBX10\sharepoint">
    <Site Id="2e4d5a29-8e4a-4403-8a14-4ceb454c74d3" OwnerLogin="NA\pdssbx" InSiteMap="True">
      <Webs Count="1">
        <Web Id="cd21314c-e8e2-46cf-a8e5-a9392bda6526" Url="/sites/mmd1" LanguageId="1033" TemplateName="STS#0" TemplateId="1" />
      </Webs>
    </Site>
  </Database>

5.       API or Powershell – Complicated but much flexible to generate the formatted report and even send email used by developers
You could use SharePoint API to get SPWeb.WebTemplate property of a site. You could format the report to display all site collections and site for the whole farm. You could generate the nice report and send emails. Here is the simple code using API. You could find other example for powershell. Here is code snippet to list all sites.

SPWeb web = site.OPenWeb(“url”);
       templateName = web.WebTemplate;
       templateID = web.WebTemplateId;


6.       Database query – simple query for DBA
If you are DBA, you may login to the sql server management studio and execute below query on the content database of the application. Please note the dbo.Webs is a database view and the return WebTemplate is the site template ID. You need to associate the ID with template name.
SELECT Title, WebTemplate FROM dbo.Webs WHERE Title='Test Site'

Now, you have different ways to identify what template is used for the site for SharePoint sites. If you need to know more about the site definition for the site, append the  /_vti_bin/owssvr.dll?Cmd=GetProjSchema to the site URL (ex. http://sbx01/sites/Harry/_vti_bin/owssvr.dll?Cmd=GetProjSchema). You will have another whole world you could explore.

No comments:

Post a Comment