Determine the site template used to create SharePoint sites

Print This Post Print This Post

I was facing an issue where two site which were look alike but behaved differently, the navigation and bread crumbs were laid differently. We have a standard process to using pre defined templates and as per the request for site creation both the site were suppose to have Team Site template and I guess they were created as per the process defined.

When users had issue they asked to introspect on what going with these site. The first thing I wanted to know indeed was templates used to create the sites. I poked around the site settings pages but could not find any information on which page template was used. I then turned to central admin but in vain. I quickly posted to the MSDN forums, I was sure someone would have already gone through this and there would a way or code which existed.

As per my expectation I got a reply which pointed me to this page on Rafelo’s blog. All credits to Rafelo for such short code. See the code and instructions below

<%@ 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()
{
  SPWeb thisWeb = this.Web;
  lblWebTempalte.Text = thisWeb.WebTemplate;
  lblWebTemplateID.Text = thisWeb.WebTemplateId.ToString();
});
}
</script>
<asp:Content ID="Main" runat="server" contentplaceholderid="PlaceHolderMain" >
<p>
Web Template: <asp:Label ID="lblWebTempalte" 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>

Save the page to your layouts folder (usually c:\program files\common files\microsoft shared\web server extensions\12\template\layouts\). Once the page has been saved, you can access it from any of your SharePoint sites via http://yoursharepointsiteaddress/_layouts/pagename.aspx


Print This Post Print This Post
About this entry