Class Template
Represents a Template file.
Namespace: Umbraco.Cms.Core.Models
Assembly: Umbraco.Core.dll
Syntax
[DataContract(IsReference = true)]
public class Template : File, ITemplate, IFile, IEntity, IDeepCloneable, IRememberBeingDirty, ICanBeDirty
Constructors
View SourceTemplate(IShortStringHelper, string?, string?)
Initializes a new instance of the Template class.
Declaration
public Template(IShortStringHelper shortStringHelper, string? name, string? alias)
Parameters
| Type | Name | Description |
|---|---|---|
| IShortStringHelper | shortStringHelper | The short string helper for alias cleaning. |
| string | name | The name of the template. |
| string | alias | The alias of the template. |
Template(IShortStringHelper, string?, string?, Func<File, string?>?)
Initializes a new instance of the Template class.
Declaration
public Template(IShortStringHelper shortStringHelper, string? name, string? alias, Func<File, string?>? getFileContent)
Parameters
| Type | Name | Description |
|---|---|---|
| IShortStringHelper | shortStringHelper | The short string helper for alias cleaning. |
| string | name | The name of the template. |
| string | alias | The alias of the template. |
| Func<File, string> | getFileContent | A function to retrieve the file content lazily. |
Properties
View SourceAlias
Gets or sets the alias of the template.
Declaration
[DataMember]
public string Alias { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Remarks
The alias is automatically cleaned using the underscore alias format.
IsLayoutTemplate
Returns true if the template is used as a layout for other templates (i.e. it has 'children')
Declaration
public bool IsLayoutTemplate { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
IsMasterTemplate
Returns true if the template is used as a layout for other templates (i.e. it has 'children')
Declaration
[Obsolete("Use IsLayoutTemplate instead. Scheduled for removal in Umbraco 20.")]
public bool IsMasterTemplate { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
LayoutTemplateAlias
Gets or sets the alias of the layout (parent) template.
Declaration
public string? LayoutTemplateAlias { get; set; }
Property Value
| Type | Description |
|---|---|
| string | The alias of the layout template, or |
LayoutTemplateId
Gets or sets the layout template identifier as a lazy-loaded value.
Declaration
[DataMember]
public Lazy<int>? LayoutTemplateId { get; set; }
Property Value
| Type | Description |
|---|---|
| Lazy<int> | A System.Lazy<T> containing the layout template's ID, or -1 if there is no layout template. |
MasterTemplateAlias
Gets or sets the alias of the layout (parent) template.
Declaration
[Obsolete("Use LayoutTemplateAlias instead. Scheduled for removal in Umbraco 20.")]
public string? MasterTemplateAlias { get; set; }
Property Value
| Type | Description |
|---|---|
| string | The alias of the layout template, or |
MasterTemplateId
Gets or sets the layout template identifier as a lazy-loaded value.
Declaration
[Obsolete("Use LayoutTemplateId instead. Scheduled for removal in Umbraco 20.")]
public Lazy<int>? MasterTemplateId { get; set; }
Property Value
| Type | Description |
|---|---|
| Lazy<int> | A System.Lazy<T> containing the layout template's ID, or -1 if there is no layout template. |
Name
Gets or sets the name of the template.
Declaration
[DataMember]
public string? Name { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
View SourceDeepCloneNameAndAlias(File)
Overrides the base implementation to prevent File from cloning name and alias.
Declaration
protected override void DeepCloneNameAndAlias(File clone)
Parameters
| Type | Name | Description |
|---|---|---|
| File | clone | The cloned file instance. |