SPWebTemplate Class
Represents either a site definition configuration or a Web template that is used to create SharePoint sites.
Inheritance Hierarchy
System.Object
Microsoft.SharePoint.SPWebTemplate
Microsoft.SharePoint.SPCustomWebTemplate
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online
Syntax
'Declaration
<SubsetCallableTypeAttribute> _
<ClientCallableTypeAttribute(Name := "WebTemplate", ServerTypeId := "{2be10268-4be1-4b5a-850d-d06b137a9c40}")> _
Public Class SPWebTemplate
'Usage
Dim instance As SPWebTemplate
[SubsetCallableTypeAttribute]
[ClientCallableTypeAttribute(Name = "WebTemplate", ServerTypeId = "{2be10268-4be1-4b5a-850d-d06b137a9c40}")]
public class SPWebTemplate
Remarks
Site definition configurations are contained in files within %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE, while Web templates are stored as .wsp files in the SharePoint Foundation database.
Use the GetCustomWebTemplates method of the SPSite class to return the collection of Web templates created through the user interface or the object model, or use the GetWebTemplates method of the SPSite class to return the collection of site definition configurations in the site collection. After you have a reference to a collection, use an indexer to return a single site definition configuration or site template. For example, if the collection is assigned to a variable named mySiteTemplates, use mySiteTemplates[index] in Microsoft Visual C#, or mySiteTemplates(index) in Microsoft Visual Basic, where index is either the title or the index number in the collection of the site definition configuration or Web template.
A site definition, which is a kind of container for one or more site definition configurations, is expressed, in Collaborative Application Markup Language (CAML) markup, by a Template element in a WebTemp*.xml file in the directory %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\LCID\XML\, where LCID is the numeric ID of your language/culture such as 1033 for English. How a site definition configuration appears in the UI when a user is creating a new site is determined by one of the child <Configuration> elements of the Template element. Details of the site definition configuration are stored in one of the Configuration elements in the Onet.xml file in the directory %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\SiteTemplates\site_type\XML\, where site_type is "STS," “SGS,” "MPS," "BLOG," "WIKI," "CENTRALADMIN," “TENANTADMIN,” or the name of a custom site definition.
A Web template is defined in an elements.xml file that is compressed into the .wsp file. (An .wsp file is a CAB file. You can open it in Windows Explorer if you first change the extension to .cab.)
Note
While an SPWebTemplate can represent either a site definition configuration or a custom Web template, an SPCustomWebTemplate always represents a custom Web template.
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
See Also
Reference
Microsoft.SharePoint Namespace
Other Resources
Understanding WebTemp*.xml Files
Collaborative Application Markup Language (CAML)