Determine which Site template was used to create a site collection

Received this question today from one of my colleagues and I knew that you could find out this information by accessing the dbo.Webs table in the Content Database of the site collection, but I was sure that there would be a better way to find this out. So I dug a little around the net and found a comment on a blog having a good solution:

This wa a comment posted by Rafelo (http://blog.rafelo.com)

You can determine the site definition / template used to create the site, via the WebTemplate and WebTemplateID properties of the SPWeb object (via the API). If you dont feel comfortable coding something or simply dont know how there is a fantastic tool from Carsten Keutman called SharePoint Manager which exposes most of the SharePoint API for you (download also here). It’s a desktop application that you run on one of the SharePoint servers on the farm. Alternatively you could save the following code as an aspx page to your layouts folder (\program files\common files\microsoft shared\web server extensions\12\template\layouts):


 




Code Snippet

<%@ Assembly Name=”Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”%>
<%@ Page Language=”C#” MasterPageFile=”~/_layouts/application.master” Inherits=”Microsoft.SharePoint.WebControls.LayoutsPageBase” %>
<%@ Import Namespace=”Microsoft.SharePoint” %>


<script runat=”server”>
   
   
    protected override void OnLoad(EventArgs e){
        SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPWeb thisWeb = this.Web)
                {
                    lblWebTemplate.Text = thisWeb.WebTemplate;
                    lblWebTemplateID.Text = thisWeb.WebTemplateId.ToString();
                }
            });
    }
</script>
<asp:Content ID=”Main” runat=”server” contentplaceholderid=”PlaceHolderMain” >
    <p>
    Web Template: <asp:Label ID=”lblWebTemplate” runat=”server” />
    </p>
    Web Template ID: <asp:Label ID=”lblWebTemplateID” runat=”server” />
</asp:Content>


<asp:Content ID=”PageTitle” runat=”server” contentplaceholderid=”PlaceHolderPageTitle” >
  Site Template Information
</asp:Content>


<asp:Content ID=”PageTitleInTitleArea” runat=”server” contentplaceholderid=”PlaceHolderPageTitleInTitleArea” >
  Site Template Information
</asp:Content>


 


 



Once you have saved the page, you can access it via http://yourwebaddress/yoursite/_layouts/pagename.aspx


The page should look something like this:



You can find a reference to these identifiers in one of my previous posts: http://dirkvandenberghe.com/archive/2007/11/21/site-template-identifiers-for-use-with-stsadm.aspx


My advise to all of you now is to create this aspx page using notepad and save it to all your frontends. This way even your site collection admins can find out the template name. Another advise would be to include a table on this page with the reference to the identifiers as well.


 

Goodbye Siemens, Welcome BT

Just wanted you all to know that I will be trading in my position at    for a position at BT


As of July 16th 2008, i will no longer be be working at Siemens IT solutions and Services, where I have enjoyed working for the last 7 years. I will start a new challenge at BT in Diegem, Belgium as a Technology Lead Consultant for Microsoft products, such as Sharepoint, OCS and Exchange.


I am very eager to start and can’t wait until half of July.


This change does not mean the end of this blog, on the contrary.


 So stay tuned for more news soon,.