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)
Syntax
'Declaration
Public Class SPWebTemplate
'Usage
Dim instance As SPWebTemplate
public class SPWebTemplate
Remarks
Site definition configurations are contained in files within %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\15\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\15\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\15\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
Collaborative Application Markup Language (CAML)
How to: Create a Web Site Definition from an Existing Web Site Definition