SilverStripe\CMS\Model\SiteTreeLinkTracking
Adds tracking of links in any HTMLText fields which reference SiteTree or File items.
Attaching this to any DataObject will add four fields which contain all links to SiteTree and File items
referenced in any HTMLText fields, and two booleans to indicate if there are any broken links. Call
augmentSyncLinkTracking to update those fields with any changes to those fields.
Note that since both SiteTree and File are versioned, LinkTracking and FileTracking will
only be enabled for the Stage record.
Note: To support `HasBrokenLink` for non-SiteTree classes, add a boolean `HasBrokenLink`
field to your `db` config and this extension will ensure it's flagged appropriately.
Synopsis
class SiteTreeLinkTracking
extends DataExtension
{
- // members
- protected SiteTreeLinkTracking_Parser $parser;
- private static array $dependencies = ;
- private static array $many_many = ;
- private static boolean $show_sitetree_link_tracking = false;
- // methods
- public SiteTreeLinkTracking_Parser getParser()
- public $this setParser()
- public void onBeforeWrite()
- public void syncLinkTracking()
- public void augmentSyncLinkTracking()
- public void onAfterDelete()
- public array trackLinksInField()
- protected void toggleElementClass()
- public void updateCMSFields()
Hierarchy
Extends
- SilverStripe\ORM\DataExtension
Members
private
- $dependencies
—
array
Inject parser for each page - $many_many
- $show_sitetree_link_tracking
—
boolean
Controls visibility of the Link Tracking tab
protected
Methods
protected
- toggleElementClass() — Add the given css class to the DOM element.
public
- augmentSyncLinkTracking() — Find HTMLText fields on {@link owner} to scrape for links that need tracking
- getParser() — Parser for link tracking
- onAfterDelete()
- onBeforeWrite()
- setParser()
- syncLinkTracking() — Public method to call when triggering symlink extension. Can be called externally, or overridden by class implementations.
- trackLinksInField() — Scrape the content of a field to detect anly links to local SiteTree pages or files
- updateCMSFields()