Download the PHP package fromholdio/silverstripe-dbhtmlanchors without Composer
On this page you can find all versions of the php package fromholdio/silverstripe-dbhtmlanchors. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download fromholdio/silverstripe-dbhtmlanchors
More information about fromholdio/silverstripe-dbhtmlanchors
Files in fromholdio/silverstripe-dbhtmlanchors
Package silverstripe-dbhtmlanchors
Short Description Quick and easy method of identifying anchors in DBHTMLText and DBHTMLVarchar fields
License BSD-3-Clause
Homepage https://github.com/fromholdio/silverstripe-dbhtmlanchors
Informations about the package silverstripe-dbhtmlanchors
silverstripe-dbhtmlanchors
Quick and easy method of identifying anchors in DBHTMLText and DBHTMLVarchar fields.
Requirements
SilverStripe 4
Installation
composer require fromholdio/silverstripe-dbhtmlanchors
Detail
Upon install, the DBHTMLAnchorsExtension
is automatically applied to DBHTMLText
and DBHTMLVarchar
.
This adds a getAnchors()
accessor to each of these DBFields.
When called on the field object, it processes any shortcodes, and then searches the html elements for name
and id
attributes that can be used as anchor link targets.
The list of anchor values is returned as a simple array.
Usage example
Add a DBHTMLText
or DBHTMLVarchar
to your data object. The Content
field of SiteTree
is a common example of one that already exists.
In your code, get the field object, and call getAnchors()
. Make sure you get the field object, not the field's value.
The value returned will be either null
for no results, or an associative array, with key and value both containing the anchor value.