Documentation > CMS Template API Library > Asset > SetTemplate(Int32)
SetTemplate
Set a template on an asset. The id must be the id of a folder that contains plugin files such as output.asp or input.aspx, etc.
public System.Boolean SetTemplate(Int32)
Returns
true if the template is changed, false if not
Parameters
Name | Description | Type |
---|---|---|
templateId | The template(folder) id | System.Int32 |
Code Example
C#
Sample:
1 2 3 4 5 6 | Asset anAsset = Asset.Load( "/Path/ToChange" ); Asset template = Asset.Load( "/System/Templates/MyTemplate" ); if (!anAsset.SetTemplate(template.Id)) { Out.DebugWriteLine( "Failed to set asset id {0} to new template id {1} error {2}" , anAsset.Id, template.Id, context.Error); } |