Skip to content

LinkData ​

Type
Class
Namespace
craft\fields\data
Inherits
craft\fields\data\LinkData » yii\base\BaseObject
Implements
craft\base\Serializable, yii\base\Configurable
Since
5.3.0

Link field data class.

View source

Public Properties ​

PropertyDescription
ariaLabelstring, null – The link’s aria-label attribute.
classstring, null – The link’s class attribute.
elementcraft\base\ElementInterface, null – The element linked by the field, if there is one
elementQuerycraft\elements\db\ElementQueryInterface, null – An element query that will fetch the element linked by the field, if there is one
idstring, null – The link’s id attribute.
labelstring – The link label
link\Twig\Markup, null – An anchor tag for this link
relstring, null – The link’s rel attribute.
targetstring, null – The link’s target attribute.
titlestring, null – The link’s title attribute.
typestring – The link type ID
urlstring – The full link URL, including the suffix
urlSuffixstring, null – The link’s URL suffix value.
valuestring – The link value

ariaLabel ​

Type
string, null
Default value
null
Since
5.6.0

The link’s aria-label attribute.

View source

class ​

Type
string, null
Default value
null
Since
5.6.0

The link’s class attribute.

View source

element ​

Type
craft\base\ElementInterface, null
Default value
null

The element linked by the field, if there is one

View source

elementQuery ​

Type
craft\elements\db\ElementQueryInterface, null
Default value
null

An element query that will fetch the element linked by the field, if there is one

View source

id ​

Type
string, null
Default value
null
Since
5.6.0

The link’s id attribute.

View source

label ​

Type
string
Default value
null

The link label

View source

Type
\Twig\Markup, null
Default value
null

An anchor tag for this link

View source

rel ​

Type
string, null
Default value
null
Since
5.6.0

The link’s rel attribute.

View source

target ​

Type
string, null
Default value
null
Since
5.5.0

The link’s target attribute.

View source

title ​

Type
string, null
Default value
null
Since
5.6.0

The link’s title attribute.

View source

type ​

Type
string
Default value
null

The link type ID

View source

url ​

Type
string
Default value
null

The full link URL, including the suffix

View source

urlSuffix ​

Type
string, null
Default value
null
Since
5.6.0

The link’s URL suffix value.

View source

value ​

Type
string
Default value
null

The link value

View source

Public Methods ​

MethodDescription
__call()Calls the named method which is not a class method.
__construct()
__get()Returns the value of an object property.
__isset()Checks if a property is set, i.e. defined and not null.
__set()Sets value of an object property.
__toString()
__unset()Sets an object property to null.
canGetProperty()Returns a value indicating whether a property can be read.
canSetProperty()Returns a value indicating whether a property can be set.
className()Returns the fully qualified name of this class.
getElement()Returns the element linked by the field, if there is one.
getElementQuery()Returns an element query that will fetch the element linked by the field, if there is one.
getLabel()Returns the link label.
getLink()Returns an anchor tag for this link.
getType()Returns the link type ID.
getUrl()Returns the full link URL.
getValue()Returns the link value.
hasMethod()Returns a value indicating whether a method is defined.
hasProperty()Returns a value indicating whether a property is defined.
init()Initializes the object.
serialize()
setLabel()Sets the link label.

__construct() ​

View source

Arguments ​

  • $value
  • $linkType
  • $config

__toString() ​

View source

getElement() ​

Returns the element linked by the field, if there is one.

View source

Returns ​

craft\base\ElementInterface, null

getElementQuery() ​

Since
5.6.0

Returns an element query that will fetch the element linked by the field, if there is one.

View source

Returns ​

craft\elements\db\ElementQueryInterface, null

getLabel() ​

Returns the link label.

View source

Arguments ​

  • $custom (boolean, null) – Whether to return the custom label

Returns ​

string, null

Returns an anchor tag for this link.

View source

Returns ​

\Twig\Markup

getType() ​

Returns the link type ID.

View source

Returns ​

string

getUrl() ​

Since
5.6.0

Returns the full link URL.

View source

getValue() ​

Returns the link value.

View source

serialize() ​

View source

setLabel() ​

Since
5.5.0

Sets the link label.

View source

Arguments ​