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
Since
3.0

ElementTrait implements the common methods and properties for element classes.

View source

Public Properties

PropertyDescription
$archivedboolean – Whether the element is archived
$awaitingFieldValuesboolean – Whether the element is still awaiting its custom field values
$contentIdinteger, null – The element’s content row ID
$dateCreatedDateTime, null – The date that the element was created
$dateUpdatedDateTime, null – The date that the element was last updated
$enabledboolean – Whether the element is enabled
$enabledForSiteboolean – Whether the element is enabled for this site.
$fieldLayoutIdinteger, null – The element’s field layout ID
$idinteger, null – The element’s ID
$levelinteger, null – The element’s level within its structure
$lftinteger, null – The element’s left position within its structure
$propagatingboolean – Whether the element is being saved in the context of propagating another site's version of the element.
$rgtinteger, null – The element’s right position within its structure
$rootinteger, null – The element’s structure’s root ID
$searchScoreinteger, null – The element’s search score, if the craft\elements\db\ElementQuery::search() parameter was used when querying for the element
$siteIdinteger, null – The site ID the element is associated with
$slugstring, null – The element’s slug
$structureIdinteger, null – The element’s structure ID
$tempIdstring, null – The element’s temporary ID (only used if the element's URI format contains {id})
$titlestring, null – The element’s title
$uidstring, null – The element’s UID
$uristring, null – The element’s URI

$archived

Type
boolean

Whether the element is archived

View source

Signature

public boolean $archived = false

$awaitingFieldValues

Type
boolean

Whether the element is still awaiting its custom field values

View source

Signature

public boolean $awaitingFieldValues = false

$contentId

Type
integer, null

The element’s content row ID

View source

Signature

public integer, null $contentId = null

$dateCreated

Type
DateTime, null

The date that the element was created

View source

Signature

public DateTime, null $dateCreated = null

$dateUpdated

Type
DateTime, null

The date that the element was last updated

View source

Signature

public DateTime, null $dateUpdated = null

$enabled

Type
boolean

Whether the element is enabled

View source

Signature

public boolean $enabled = true

$enabledForSite

Type
boolean

Whether the element is enabled for this site.

View source

Signature

public boolean $enabledForSite = true

$fieldLayoutId

Type
integer, null

The element’s field layout ID

View source

Signature

public integer, null $fieldLayoutId = null

$id

Type
integer, null
Access
Read-only

The element’s ID

View source

Signature

public integer, null getId ( )

$level

Type
integer, null

The element’s level within its structure

View source

Signature

public integer, null $level = null

$lft

Type
integer, null

The element’s left position within its structure

View source

Signature

public integer, null $lft = null

$propagating

Type
boolean

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

View source

Signature

public boolean $propagating = false

$rgt

Type
integer, null

The element’s right position within its structure

View source

Signature

public integer, null $rgt = null

$root

Type
integer, null

The element’s structure’s root ID

View source

Signature

public integer, null $root = null

$searchScore

Type
integer, null

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

View source

Signature

public integer, null $searchScore = null

$siteId

Type
integer, null

The site ID the element is associated with

View source

Signature

public integer, null $siteId = null

$slug

Type
string, null

The element’s slug

View source

Signature

public string, null $slug = null

$structureId

Type
integer, null

The element’s structure ID

View source

Signature

public integer, null $structureId = null

$tempId

Type
string, null

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

View source

Signature

public string, null $tempId = null

$title

Type
string, null

The element’s title

View source

Signature

public string, null $title = null

$uid

Type
string, null

The element’s UID

View source

Signature

public string, null $uid = null

$uri

Type
string, null
Access
Read-only

The element’s URI

View source

Signature

public string getUri ( \craft\elements\string $filename = null )