ElementTrait

Type
Trait
Namespace
craft\base
Implemented by
craft\base\Element, craft\elements\Asset, craft\elements\Category, craft\elements\Entry, craft\elements\GlobalSet, craft\elements\MatrixBlock, craft\elements\Tag, craft\elements\User, craft\models\BaseEntryRevisionModel, craft\models\EntryDraft, craft\models\EntryVersion, craft\test\mockclasses\elements\ExampleElement
Since
3.0.0

ElementTrait implements the common methods and properties for element classes.

View source (opens new window)

# Public Properties

Property Description
archived boolean (opens new window) – Whether the element is archived
awaitingFieldValues boolean (opens new window) – Whether the element is still awaiting its custom field values
contentId integer (opens new window), null (opens new window) – The element’s content row ID
dateCreated DateTime (opens new window), null (opens new window) – The date that the element was created
dateDeleted DateTime (opens new window), null (opens new window) – The date that the element was trashed
dateUpdated DateTime (opens new window), null (opens new window) – The date that the element was last updated
draftId integer (opens new window), null (opens new window) – The ID of the draft’s row in the drafts table
duplicateOf craft\base\ElementInterface, null (opens new window) – The element that this element is being duplicated by.
enabled boolean (opens new window) – Whether the element is enabled
fieldLayoutId integer (opens new window), null (opens new window) – The element’s field layout ID
hardDelete boolean (opens new window) – Whether the element is being hard-deleted.
id integer (opens new window), null (opens new window) – The element’s ID
level integer (opens new window), null (opens new window) – The element’s level within its structure
lft integer (opens new window), null (opens new window) – The element’s left position within its structure
newSiteIds integer (opens new window)[] – The site IDs that the element was just propagated to for the first time.
previewing boolean (opens new window) – Whether the element is currently being previewed.
propagateAll boolean (opens new window) – Whether all element attributes should be propagated across all its supported sites, even if that means overwriting existing site-specific values.
propagating boolean (opens new window) – Whether the element is being saved in the context of propagating another site's version of the element.
resaving boolean (opens new window) – Whether the element is being resaved by a ResaveElement job or a resave console command.
revisionId integer (opens new window) – The ID of the revision’s row in the revisions table
rgt integer (opens new window), null (opens new window) – The element’s right position within its structure
root integer (opens new window), null (opens new window) – The element’s structure’s root ID
searchScore integer (opens new window), null (opens new window) – The element’s search score, if the craft\elements\db\ElementQuery::search() parameter was used when querying for the element
siteId integer (opens new window), null (opens new window) – The site ID the element is associated with
siteSettingsId integer (opens new window), null (opens new window) – The ID of the element’s record in the elements_sites table
slug string (opens new window), null (opens new window) – The element’s slug
structureId integer (opens new window), null (opens new window) – The element’s structure ID
tempId string (opens new window), null (opens new window) – The element’s temporary ID (only used if the element's URI format contains {id})
title string (opens new window), null (opens new window) – The element’s title
trashed boolean (opens new window) – Whether the element has been soft-deleted.
uid string (opens new window), null (opens new window) – The element’s UID
uri string (opens new window), null (opens new window) – The element’s URI

# archived

Type
boolean (opens new window)
Default value
false

Whether the element is archived

View source (opens new window)

# awaitingFieldValues

Type
boolean (opens new window)
Default value
false

Whether the element is still awaiting its custom field values

View source (opens new window)

# contentId

Type
integer (opens new window), null (opens new window)
Default value
null

The element’s content row ID

View source (opens new window)

# dateCreated

Type
DateTime (opens new window), null (opens new window)
Default value
null

The date that the element was created

View source (opens new window)

# dateDeleted

Type
DateTime (opens new window), null (opens new window)
Default value
null
Since
3.2.0

The date that the element was trashed

View source (opens new window)

# dateUpdated

Type
DateTime (opens new window), null (opens new window)
Default value
null

The date that the element was last updated

View source (opens new window)

# draftId

Type
integer (opens new window), null (opens new window)
Default value
null
Since
3.2.0

The ID of the draft’s row in the drafts table

View source (opens new window)

# duplicateOf

Type
craft\base\ElementInterface, null (opens new window)
Default value
null

The element that this element is being duplicated by.

View source (opens new window)

# enabled

Type
boolean (opens new window)
Default value
true

Whether the element is enabled

View source (opens new window)

# fieldLayoutId

Type
integer (opens new window), null (opens new window)
Default value
null

The element’s field layout ID

View source (opens new window)

# hardDelete

Type
boolean (opens new window)
Default value
false
Since
3.2.0

Whether the element is being hard-deleted.

View source (opens new window)

# id

Type
integer (opens new window), null (opens new window)
Default value
null

The element’s ID

View source (opens new window)

# level

Type
integer (opens new window), null (opens new window)
Default value
null

The element’s level within its structure

View source (opens new window)

# lft

Type
integer (opens new window), null (opens new window)
Default value
null

The element’s left position within its structure

View source (opens new window)

# newSiteIds

Type
integer (opens new window)[]
Default value
[]
Since
3.2.9

The site IDs that the element was just propagated to for the first time.

View source (opens new window)

# previewing

Type
boolean (opens new window)
Default value
false
Since
3.2.0

Whether the element is currently being previewed.

View source (opens new window)

# propagateAll

Type
boolean (opens new window)
Default value
false
Since
3.2.0

Whether all element attributes should be propagated across all its supported sites, even if that means overwriting existing site-specific values.

View source (opens new window)

# propagating

Type
boolean (opens new window)
Default value
false

Whether the element is being saved in the context of propagating another site's version of the element.

View source (opens new window)

# resaving

Type
boolean (opens new window)
Default value
false
Since
3.1.22

Whether the element is being resaved by a ResaveElement job or a resave console command.

View source (opens new window)

# revisionId

Type
integer (opens new window)
Default value
null
Since
3.2.0

The ID of the revision’s row in the revisions table

View source (opens new window)

# rgt

Type
integer (opens new window), null (opens new window)
Default value
null

The element’s right position within its structure

View source (opens new window)

# root

Type
integer (opens new window), null (opens new window)
Default value
null

The element’s structure’s root ID

View source (opens new window)

# searchScore

Type
integer (opens new window), null (opens new window)
Default value
null

The element’s search score, if the craft\elements\db\ElementQuery::search() parameter was used when querying for the element

View source (opens new window)

# siteId

Type
integer (opens new window), null (opens new window)
Default value
null

The site ID the element is associated with

View source (opens new window)

# siteSettingsId

Type
integer (opens new window), null (opens new window)
Default value
null
Since
3.5.2

The ID of the element’s record in the elements_sites table

View source (opens new window)

# slug

Type
string (opens new window), null (opens new window)
Default value
null

The element’s slug

View source (opens new window)

# structureId

Type
integer (opens new window), null (opens new window)
Default value
null

The element’s structure ID

View source (opens new window)

# tempId

Type
string (opens new window), null (opens new window)
Default value
null

The element’s temporary ID (only used if the element's URI format contains {id})

View source (opens new window)

# title

Type
string (opens new window), null (opens new window)
Default value
null

The element’s title

View source (opens new window)

# trashed

Type
boolean (opens new window)
Default value
false

Whether the element has been soft-deleted.

View source (opens new window)

# uid

Type
string (opens new window), null (opens new window)
Default value
null

The element’s UID

View source (opens new window)

# uri

Type
string (opens new window), null (opens new window)
Default value
null

The element’s URI

View source (opens new window)