Search Results for

    Show / Hide Table of Contents
    View Source

    Class ContentType

    Represents the content type that a Content object is based on

    Inheritance
    object
    BeingDirtyBase
    EntityBase
    TreeEntityBase
    ContentTypeBase
    ContentTypeCompositionBase
    Namespace: Umbraco.Cms.Core.Models
    Assembly: Umbraco.Core.dll
    Syntax
    [Serializable]
    [DataContract(IsReference = true)]
    public class ContentType : ContentTypeCompositionBase, IContentType, IContentTypeComposition, IContentTypeBase, IUmbracoEntity, ITreeEntity, IEntity, IDeepCloneable, IRememberBeingDirty, ICanBeDirty

    Constructors

    View Source

    ContentType(IShortStringHelper, int)

    Constuctor for creating a ContentType with the parent's id.

    Declaration
    public ContentType(IShortStringHelper shortStringHelper, int parentId)
    Parameters
    Type Name Description
    IShortStringHelper shortStringHelper
    int parentId
    Remarks

    Only use this for creating ContentTypes at the root (with ParentId -1).

    View Source

    ContentType(IShortStringHelper, IContentType, string)

    Constuctor for creating a ContentType with the parent as an inherited type.

    Declaration
    public ContentType(IShortStringHelper shortStringHelper, IContentType parent, string alias)
    Parameters
    Type Name Description
    IShortStringHelper shortStringHelper
    IContentType parent
    string alias
    Remarks

    Use this to ensure inheritance from parent.

    Fields

    View Source

    SupportsPublishingConst

    Declaration
    public const bool SupportsPublishingConst = true
    Field Value
    Type Description
    bool

    Properties

    View Source

    AllowedTemplates

    Gets or Sets a list of Templates which are allowed for the ContentType TODO: This should be ignored from cloning!!!!!!!!!!!!!!

    • but to do that we have to implement callback hacks, this needs to be fixed in v8, we should not store direct entity
    Declaration
    [DataMember]
    public IEnumerable<ITemplate>? AllowedTemplates { get; set; }
    Property Value
    Type Description
    IEnumerable<ITemplate>
    View Source

    DefaultTemplate

    Gets or sets the alias of the default Template. TODO: This should be ignored from cloning!!!!!!!!!!!!!!

    • but to do that we have to implement callback hacks, this needs to be fixed in v8, we should not store direct entity
    Declaration
    [IgnoreDataMember]
    public ITemplate? DefaultTemplate { get; }
    Property Value
    Type Description
    ITemplate
    View Source

    DefaultTemplateId

    Internal property to store the Id of the default template

    Declaration
    [DataMember]
    public int DefaultTemplateId { get; set; }
    Property Value
    Type Description
    int
    View Source

    HistoryCleanup

    Gets or sets the history cleanup configuration.

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

    The history cleanup configuration.

    View Source

    SupportsPublishing

    Gets a value indicating whether the content type supports publishing.

    Declaration
    public override bool SupportsPublishing { get; }
    Property Value
    Type Description
    bool
    Remarks

    A publishing content type supports draft and published values for properties. It is possible to retrieve either the draft (default) or published value of a property. Setting the value always sets the draft value, which then needs to be published.

    A non-publishing content type only supports one value for properties. Getting the draft or published value of a property returns the same thing, and publishing a value property has no effect.

    Methods

    View Source

    IsAllowedTemplate(int)

    Determines if AllowedTemplates contains templateId

    Declaration
    public bool IsAllowedTemplate(int templateId)
    Parameters
    Type Name Description
    int templateId

    The template id to check

    Returns
    Type Description
    bool

    True if AllowedTemplates contains the templateId else False

    View Source

    IsAllowedTemplate(string)

    Determines if AllowedTemplates contains templateId

    Declaration
    public bool IsAllowedTemplate(string templateAlias)
    Parameters
    Type Name Description
    string templateAlias

    The template alias to check

    Returns
    Type Description
    bool

    True if AllowedTemplates contains the templateAlias else False

    View Source

    IsDirty()

    Indicates whether the current entity is dirty.

    Declaration
    public override bool IsDirty()
    Returns
    Type Description
    bool

    True if entity is dirty, otherwise False

    View Source

    RemoveTemplate(ITemplate)

    Removes a template from the list of allowed templates

    Declaration
    public bool RemoveTemplate(ITemplate template)
    Parameters
    Type Name Description
    ITemplate template

    ITemplate to remove

    Returns
    Type Description
    bool

    True if template was removed, otherwise False

    View Source

    SetDefaultTemplate(ITemplate?)

    Sets the default template for the ContentType

    Declaration
    public void SetDefaultTemplate(ITemplate? template)
    Parameters
    Type Name Description
    ITemplate template

    Default ITemplate

    View Source

    ToSimple()

    Gets an ISimpleContentType corresponding to this content type.

    Declaration
    public override ISimpleContentType ToSimple()
    Returns
    Type Description
    ISimpleContentType
    • Edit this page
    • View Source
    In this article
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX