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.
Public Properties ​
| Property | Description |
|---|---|
| ariaLabel | string, null – The link’s aria-label attribute. |
| class | string, null – The link’s class attribute. |
| download | boolean – Whether the link should have a download attribute. |
| element | craft\base\ElementInterface, null – The element linked by the field, if there is one |
| elementQuery | craft\elements\db\ElementQueryInterface, null – An element query that will fetch the element linked by the field, if there is one |
| filename | string, null – The download filename |
| id | string, null – The link’s id attribute. |
| label | string – The link label |
| link | \Twig\Markup, null – An anchor tag for this link |
| rel | string, null – The link’s rel attribute. |
| target | string, null – The link’s target attribute. |
| title | string, null – The link’s title attribute. |
| type | string – The link type ID |
| url | string – The full link URL, including the suffix |
| urlSuffix | string, null – The link’s URL suffix value. |
| value | string – The link value |
ariaLabel ​
The link’s aria-label attribute.
class ​
The link’s class attribute.
download ​
- Type
- boolean
- Default value
false- Since
- 5.7.0
Whether the link should have a download attribute.
element ​
- Type
- craft\base\ElementInterface, null
- Default value
null
The element linked by the field, if there is one
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
filename ​
The download filename
id ​
The link’s id attribute.
label ​
- Type
- string
- Default value
null
The link label
link ​
- Type
\Twig\Markup, null- Default value
null
An anchor tag for this link
rel ​
The link’s rel attribute.
target ​
The link’s target attribute.
title ​
The link’s title attribute.
type ​
- Type
- string
- Default value
null
The link type ID
url ​
- Type
- string
- Default value
null
The full link URL, including the suffix
urlSuffix ​
The link’s URL suffix value.
value ​
- Type
- string
- Default value
null
The link value
Public Methods ​
| Method | Description |
|---|---|
| __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. |
| getFilename() | Returns the download filename. |
| 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() | |
| setFilename() | Sets the download filename. |
| setLabel() | Sets the link label. |
__construct() ​
Arguments ​
$value$linkType$config
__toString() ​
getElement() ​
Returns the element linked by the field, if there is one.
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.
Returns ​
craft\elements\db\ElementQueryInterface, null
getFilename() ​
- Since
- 5.7.0
Returns the download filename.
Arguments ​
$custom(boolean) – Whether to return the custom filename
Returns ​
getLabel() ​
Returns the link label.
Arguments ​
Returns ​
getLink() ​
Returns an anchor tag for this link.
Returns ​
\Twig\Markup
getType() ​
Returns the link type ID.
Returns ​
getUrl() ​
- Since
- 5.6.0
Returns the full link URL.
getValue() ​
Returns the link value.
serialize() ​
setFilename() ​
- Since
- 5.7.0
Sets the download filename.
Arguments ​
setLabel() ​
- Since
- 5.5.0
Sets the link label.