Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

SPWebTemplate class

Represents either a site definition configuration or a Web template that is used to create SharePoint sites.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
[ClientCallableTypeAttribute(Name = "WebTemplate", ServerTypeId = "{2be10268-4be1-4b5a-850d-d06b137a9c40}", 
	SampleUrl = "{apiroot}/web/GetAvailableWebTemplates({languageid},{includecrosslanguage})/getbyname({templatename})")]
[SubsetCallableTypeAttribute]
public class SPWebTemplate

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.)

NoteNote

While an SPWebTemplate can represent either a site definition configuration or a custom Web template, an SPCustomWebTemplate always represents a custom Web template.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.