The Content class represents a single item in the content tree, its values are fetched directly from the database, not from the cache.
The Content
class represents a single item in the content tree, its values are fetched directly from the database, not from the cache. Notice the Content class should strictly be used for CRUD operations, not complex queries, as it is not flexible nor fast enough for this.
All content is versioned, so on each individual change, a new version is stored. Past versions can only be retrieved from the Content
api, not from the cache.
Namespace: Umbraco.Cms.Core.Models
Assembly: Umbraco.Core.dll
All samples in this document will require references to the following dll:
Umbraco.Core.dll
All samples in this document will require the following using statements:
Constructor for creating a new Content object where the necessary parameters are the name of the Content, the parent of the Content as an IContent
object and the ContentType as an IContentType
object for the Content being created. In addition, there is an optional parameter for the culture.
Constructor for creating a new Content object where the necessary parameters are the name of the Content, the parent of the Content as an IContent
object, the ContentType as an IContentType
object for the Content being created and the id of the user as a int
. In addition, there is an optional parameter for the culture.
Constructor for creating a new Content object where the necessary parameters are the name of the Content, the parent of the Content as an IContent
object, the ContentType as an IContentType
object and a PropertyCollection
for the Content being created. In addition, there is an optional parameter for the culture.
Constructor for creating a new Content object where the necessary parameters are the name of the Content, the id of the parent as int
and the ContentType as an IContentType
object for the Content being created. In addition, there is an optional parameter for the culture.
Constructor for creating a new Content object where the necessary parameters are the name of the Content, the parent id of the Content as an int
object, the ContentType as an IContentType
object for the Content being created and the id of the user as a int
. In addition, there is an optional parameter for the culture.
Constructor for creating a new Content object where the necessary parameters are the name of the Content, the id of the parent as int
, the ContentType as an IContentType
object and a PropertyCollection
for the Content being created.In addition, there is an optional parameter for the culture.
Gets or Sets a DateTime
object, indicating then the given Content was created.
Gets or Sets the Id of the User
who created the Content.
Returns a ISimpleContentType
object representing the DocumentType used by the given Content
.
Returns the id as an int
of the ContentType
object representing the DocumentType used by the given Content
.
Returns the unique Content
Id as a Int
, this ID is based on a Database identity field, and is therefore not safe to reference in code which are moved between different instances, use Key instead.
Returns the Guid
assigned to the Content during creation. This value is unique, and should never change, even if the content is moved between instances.
Gets Languages of the Content as a IEnumerable<string>
.
Gets or Sets the given Content
level in the site hierarchy as an Int
. Content placed at the root of the site, will return 1, content right underneath will return 2, and so on.
Gets or Sets the name of the content as a String
.
Gets or Sets the parent Content
Id as an Int
.
Gets or Sets the path of the content as a String
. This string contains a comma separated list of the ancestor Ids including the current contents own id at the end of the string.
Gets or Sets the IPropertyCollection
object, which is a collection of IProperty
objects. Each property corresponds to a PropertyType
, which is defined on the ContentType
.
Returns a Bool
indicating whether the given Content
is published and available on the website or not. Notice: the published flag does not check the current in-memory cache, so this flag is not a guarantee that the Content is/is not available in the cache and the frontend of the website.
If set, returns DateTime?
indicating when the Content
should be published and made available on the website and cache.
Returns the given Content
index, compared to sibling content.
Returns a IPublishedState
enum with the status of the Content being either Unpublished, Published, Publishing, Unpublishing.
Gets or sets the template id used to render the content.
Returns a Bool
indicating whether the given Content
is currently in the recycle bin.
Gets or Sets a DateTime
object, indicating when the given Content was last updated.
Returns the current Version Id as a int
, for each change made to a content item, its values are stored under a new Version. This version is identified by a int
.
Gets or Sets the Id of the User
who made the latest edit on the Content.
Gets the IProfile
object for the Creator of this Content, which contains the Id and Name of the User who created this Content item.
Gets the value of a Property as an Object
.
Gets the value of a Property as the defined type 'TPassType'.
Gets the IProfile
object for the Writer of this Content, which contains the Id and Name of the User who last updated this Content item.
Returns a Bool
indicating whether the Content object has a property with the supplied alias.
Sets the value of a property by its alias.
Returns an XElement
containing the Content data, based off the latest changes. Is used when the published content is sent to the in-memory xml cache.