$field->toLink()
Wraps a link tag around the field value. The field value is used as the link text
$field->toLink(mixed $attr1 = null, mixed $attr2 = null): string
Parameters
Name | Type | Default | Description |
---|---|---|---|
$attr1 |
mixed |
null |
Can be an optional Url. If no Url is set, the Url of the Page, File or Site will be used. Can also be an array of link attributes |
$attr2 |
mixed |
null |
If |
Return type
string
Example
The following create a link (a-tag) with the title as link text and the page url as url.
<?= $page->title()->toLink() ?>