Documentation > CMS Template API Library > Asset > SetModel(Int32)

SetModel

Sets a model on a folder. Pass the id of another folder to use as a model.

public System.Boolean SetModel(Int32)


Returns

True if it was successful

Parameters

NameDescriptionType
modelId Id of folder to be used as a model System.Int32

Code Example

C#

Sample:
Asset anAsset = Asset.Load("/Path/ToChange");
Asset model = Asset.Load("/System/Models/MyModel");
if (!anAsset.SetModel(model.Id))
{
  Out.DebugWriteLine("Failed to set asset id {0} to new model id {1} error {2}", anAsset.Id, model.Id, context.Error);
}

Connect with Crownpeak