Works just like the RedirectorPage URL/Page field
Provides and interface for creating an internal or external link.
Internal link provides a TreeDropdownField for selecting a page within the site tree
External provides a text field for entering the full URL
Also provides availability to store opening in a new tab
Silverstripe 4+
composer require iqnection-modules/linkfield
private static $db = array(
'LinkedPage' => 'Link'
);
$fields->push( IQnection\LinkField\LinkField::create($name,$title) );
setValue() expects either an array or serialized array of the following:
array(
'Location' => string ['Internal' | 'External'] (required)
'Internal' => int [SiteTree Page ID]
'External' => string [external URL | null],
'NewTab' => [bool]
);
<a href="$LinkedPage">Link Text</a>
the raw entered URL for External, or $Page->Link() for internal
an absolute URL for external (adds http://), or $Page->AbsoluteLink() for internal
for internal only, returns the linked page SiteTree object
returns URL()
returns bool, if the link is external
returns string, the location set as either Internal or External
returns _blank or self for use in a target HTML attribute
returns a full target attribute, for new tab only [target="_blank"]
pass $force=true to return attribute for both new tab and same tab
Module rating system helping users find modules that are well supported. For more on how the rating system works visit Module standards
Score not correct? Let us know there is a problem