I am sitting and partially training the Combined Knowledge MOSS 2007 Administration course with Craig Carpenter, who is here in Melbourne this week all the way from UK delivering the training in a public class held by SGC.

One of the participants in the training asked if there was a way to find out what site template was originally used to create\provision a particular SharePoint site, remembering not seeing any web parts or features that help do this. I whacked up a quick little web part nicely named the Site Template Web Part. It’s also available as a downloadable WSP package for easy deployment.

Here’s the working code example:


foreach(SPWebTemplate webTemplate in
SPContext.Current.Web.GetAvailableWebTemplates((uint)SPContext.Current.Web.Locale.LCID))

{


if (webTemplate.Name.Contains(SPContext.Current.Web.WebTemplate+“#”+SPContext.Current.Web.WebTemplateId))

{

displayMarkup = string.Format(this.DisplayHTML, webTemplate.Title, SPContext.Current.Web.WebTemplate, SPContext.Current.Web.WebTemplateId);

}

}

Download the WSP and source from here:

Advertisements