Presenter Output
This section will show you how to use the decorated value provided by the \Anomaly\UrlFieldType\UrlFieldTypePresenter
class.
UrlFieldTypePresenter::query()
The query
field type returns the URL query string as an array. An optional key
can be passed to return a specific value.
Returns: array
or string
or null
Arguments
Key | Required | Type | Default | Description |
---|---|---|---|---|
$key | false | string | null | The the query key value to return. |
Example
$id = $decorated->query('id');
Twig
ID: {{ decorated.query('id') }}
UrlFieldTypePresenter::parsed()
The parsed
method returns the parsed URL.
Returns: array
or string
or null
Arguments
Key | Required | Type | Default | Description |
---|---|---|---|---|
$key | false | string | null | The the key value to return. |
Example
$host = $decorated->parsed('host');
Twig
{{ decorated.parsed('host') }}
UrlFieldTypePresenter::link()
The link
method returns an HTML link.
Returns: string
Arguments
Key | Required | Type | Default | Description |
---|---|---|---|---|
$title | false | string | The URL | The title of the link. |
$attributes | false | array | null | The an associated array of the link attribute values. |
Example
$decorated->link('PyroCMS');
Twig
{{ decorated.link('PyroCMS')|raw }}
UrlFieldTypePresenter::to()
The to
method returns a URL to the provided path using the value as a root URL.
Returns: string
Arguments
Key | Required | Type | Default | Description |
---|---|---|---|---|
$path | false | string | null | The URI path to append to the URL. |
Example
$decorated->to('docs'); // http://pyrocms.com/docs