Search Results for

    Show / Hide Table of Contents
    View Source

    Class Template

    Represents a Template file.

    Inheritance
    object
    BeingDirtyBase
    EntityBase
    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 Source

    Template(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.

    View Source

    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 Source

    Alias

    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.

    View Source

    IsMasterTemplate

    Returns true if the template is used as a layout for other templates (i.e. it has 'children')

    Declaration
    public bool IsMasterTemplate { get; set; }
    Property Value
    Type Description
    bool
    View Source

    MasterTemplateAlias

    Gets or sets the alias of the master (parent) template.

    Declaration
    public string? MasterTemplateAlias { get; set; }
    Property Value
    Type Description
    string

    The alias of the master template, or null if this template has no master.

    View Source

    MasterTemplateId

    Gets or sets the master template identifier as a lazy-loaded value.

    Declaration
    [DataMember]
    public Lazy<int>? MasterTemplateId { get; set; }
    Property Value
    Type Description
    Lazy<int>

    A System.Lazy<T> containing the master template's ID, or -1 if there is no master template.

    View Source

    Name

    Gets or sets the name of the template.

    Declaration
    [DataMember]
    public string? Name { get; set; }
    Property Value
    Type Description
    string

    Methods

    View Source

    DeepCloneNameAndAlias(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.

    View Source

    SetMasterTemplate(ITemplate?)

    Sets the master template for this template.

    Declaration
    [Obsolete("MasterTemplate is now calculated from the content. Scheduled for removal in Umbraco 18.")]
    public void SetMasterTemplate(ITemplate? masterTemplate)
    Parameters
    Type Name Description
    ITemplate masterTemplate

    The master template to set, or null to remove the master template.

    • View Source
    In this article
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX