Class Content
Represents a Content object
Namespace: Umbraco.Cms.Core.Models
Assembly: Umbraco.Core.dll
Syntax
[Serializable]
[DataContract(IsReference = true)]
public class Content : ContentBase, IContent, IContentBase, IUmbracoEntity, ITreeEntity, IEntity, IDeepCloneable, IRememberBeingDirty, ICanBeDirty
Constructors
View SourceContent(string, int, IContentType, int, string?)
Constructor for creating a Content object
Declaration
public Content(string name, int parentId, IContentType contentType, int userId, string? culture = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Name of the content |
| int | parentId | Id of the Parent content |
| IContentType | contentType | ContentType for the current Content object |
| int | userId | The identifier of the user creating the Content object |
| string | culture | An optional culture. |
Content(string?, int, IContentType?, string?)
Constructor for creating a Content object
Declaration
public Content(string? name, int parentId, IContentType? contentType, string? culture = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Name of the content |
| int | parentId | Id of the Parent content |
| IContentType | contentType | ContentType for the current Content object |
| string | culture | An optional culture. |
Content(string?, int, IContentType?, PropertyCollection, string?)
Constructor for creating a Content object
Declaration
public Content(string? name, int parentId, IContentType? contentType, PropertyCollection properties, string? culture = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Name of the content |
| int | parentId | Id of the Parent content |
| IContentType | contentType | ContentType for the current Content object |
| PropertyCollection | properties | Collection of properties |
| string | culture | An optional culture. |
Content(string, IContent, IContentType, int, string?)
Constructor for creating a Content object
Declaration
public Content(string name, IContent parent, IContentType contentType, int userId, string? culture = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Name of the content |
| IContent | parent | Parent IContent object |
| IContentType | contentType | ContentType for the current Content object |
| int | userId | The identifier of the user creating the Content object |
| string | culture | An optional culture. |
Content(string, IContent, IContentType, string?)
Constructor for creating a Content object
Declaration
public Content(string name, IContent parent, IContentType contentType, string? culture = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Name of the content |
| IContent | parent | Parent IContent object |
| IContentType | contentType | ContentType for the current Content object |
| string | culture | An optional culture. |
Content(string, IContent, IContentType, PropertyCollection, string?)
Constructor for creating a Content object
Declaration
public Content(string name, IContent parent, IContentType contentType, PropertyCollection properties, string? culture = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Name of the content |
| IContent | parent | Parent IContent object |
| IContentType | contentType | ContentType for the current Content object |
| PropertyCollection | properties | Collection of properties |
| string | culture | An optional culture. |
Properties
View SourceBlueprint
Gets a value indicating whether the content item is a blueprint.
Declaration
[DataMember]
public bool Blueprint { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Edited
Gets a value indicating whether the content has been edited.
Declaration
[IgnoreDataMember]
public bool Edited { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Remarks
Will return true once unpublished edits have been made after the version with
PublishedVersionId has been published.
EditedCultures
Gets the edited cultures.
Declaration
[IgnoreDataMember]
public IEnumerable<string>? EditedCultures { get; set; }
Property Value
| Type | Description |
|---|---|
| IEnumerable<string> |
PublishCultureInfos
Gets the published culture infos of the content.
Declaration
[IgnoreDataMember]
public ContentCultureInfosCollection? PublishCultureInfos { get; set; }
Property Value
| Type | Description |
|---|---|
| ContentCultureInfosCollection |
Remarks
Because a dictionary key cannot be null this cannot get the invariant
name, which must be get via the PublishName property.
PublishDate
Gets the date and time the content was published.
Declaration
[IgnoreDataMember]
public DateTime? PublishDate { get; set; }
Property Value
| Type | Description |
|---|---|
| DateTime? |
PublishName
Gets the name of the published version of the content.
Declaration
[IgnoreDataMember]
public string? PublishName { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Remarks
When editing the content, the name can change, but this will not until the content is published.
PublishTemplateId
Gets the template id used to render the published version of the content.
Declaration
[IgnoreDataMember]
public int? PublishTemplateId { get; set; }
Property Value
| Type | Description |
|---|---|
| int? |
Remarks
When editing the content, the template can change, but this will not until the content is published.
Published
Gets or sets a value indicating whether this content item is published or not.
Declaration
[DataMember]
public bool Published { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Remarks
the setter is should only be invoked from
- the ContentFactory when creating a content entity from a dto
- the ContentRepository when updating a content entity
PublishedCultures
Gets the published cultures.
Declaration
[IgnoreDataMember]
public IEnumerable<string> PublishedCultures { get; }
Property Value
| Type | Description |
|---|---|
| IEnumerable<string> |
PublishedState
Gets the published state of the content item.
Declaration
[DataMember]
public PublishedState PublishedState { get; set; }
Property Value
| Type | Description |
|---|---|
| PublishedState |
Remarks
The state should be Published or Unpublished, depending on whether Published is true or false, but can also temporarily be Publishing or Unpublishing when the content item is about to be saved.
PublishedVersionId
Gets the version identifier for the currently published version of the content.
Declaration
[IgnoreDataMember]
public int PublishedVersionId { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
PublisherId
Gets the identifier of the user who published the content.
Declaration
[IgnoreDataMember]
public int? PublisherId { get; set; }
Property Value
| Type | Description |
|---|---|
| int? |
TemplateId
Gets or sets the template used by the Content. This is used to override the default one from the ContentType.
Declaration
[DataMember]
public int? TemplateId { get; set; }
Property Value
| Type | Description |
|---|---|
| int? |
Remarks
If no template is explicitly set on the Content object, the Default template from the ContentType will be returned.
Methods
View SourceDeepCloneWithResetIdentities()
Creates a deep clone of the current entity with its identity and it's property identities reset
Declaration
public IContent DeepCloneWithResetIdentities()
Returns
| Type | Description |
|---|---|
| IContent |
GetPublishDate(string)
Gets the date a culture was published.
Declaration
public DateTime? GetPublishDate(string culture)
Parameters
| Type | Name | Description |
|---|---|---|
| string | culture |
Returns
| Type | Description |
|---|---|
| DateTime? |
GetPublishName(string?)
Gets the name of the published version of the content for a given culture.
Declaration
public string? GetPublishName(string? culture)
Parameters
| Type | Name | Description |
|---|---|---|
| string | culture |
Returns
| Type | Description |
|---|---|
| string |
Remarks
When editing the content, the name can change, but this will not until the content is published.
When culture is null, gets the invariant
language, which is the value of the PublishName property.
IsCultureEdited(string)
Gets a value indicated whether a given culture is edited.
Declaration
public bool IsCultureEdited(string culture)
Parameters
| Type | Name | Description |
|---|---|---|
| string | culture |
Returns
| Type | Description |
|---|---|
| bool |
Remarks
A culture is edited when it is available, and not published or published but with changes.
A culture can be edited even though the document might now have been saved yet (and can have no identity).
Does not support the '*' wildcard (returns false).
IsCulturePublished(string)
Gets a value indicating whether a culture is published.
Declaration
public bool IsCulturePublished(string culture)
Parameters
| Type | Name | Description |
|---|---|---|
| string | culture |
Returns
| Type | Description |
|---|---|
| bool |
Remarks
A culture becomes published whenever values for this culture are published, and the content published name for this culture is non-null. It becomes non-published whenever values for this culture are unpublished.
A culture becomes published as soon as PublishCulture has been invoked, even though the document might not have been saved yet (and can have no identity).
Does not support the '*' wildcard (returns false).
IsPropertyDirty(string)
Determines whether a specific property is dirty.
Declaration
public override bool IsPropertyDirty(string propertyName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | propertyName |
Returns
| Type | Description |
|---|---|
| bool |
Remarks
Overridden to include user properties.
PerformDeepClone(object)
Used by inheritors to modify the DeepCloning logic
Declaration
protected override void PerformDeepClone(object clone)
Parameters
| Type | Name | Description |
|---|---|---|
| object | clone |
Remarks
Overridden to deal with specific object instances
ResetDirtyProperties(bool)
Resets dirty properties.
Declaration
public override void ResetDirtyProperties(bool rememberDirty)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | rememberDirty | A value indicating whether to remember dirty properties. |
Remarks
When rememberDirty is true, dirty properties are saved so they can be checked with
WasDirty.
ResetWereDirtyProperties()
Resets properties that were dirty.
Declaration
public override void ResetWereDirtyProperties()
WasPropertyDirty(string)
Determines whether a specific property was dirty.
Declaration
public override bool WasPropertyDirty(string propertyName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | propertyName |
Returns
| Type | Description |
|---|---|
| bool |
Remarks
A property was dirty if it had been changed and the changes were committed.