Source of file DoURLSegmentExtension.php
Size: 0,808 Bytes - Last Modified: 2021-12-23T10:51:54+00:00
/var/www/docs.ssmods.com/process/src/code/libs/DoURLSegmentExtension.php
1234567891011121314151617181920212223242526272829303132333435 | <?php /** * DataObject URL Segment Extension * inspired by https://github.com/dospuntocero/doarticles/blob/master/code/utils/DOArticleURLSegmentDecorator.php */ class DoURLSegmentExtension extends DataExtension { public static $db = array( 'URLSegment' => 'Varchar(255)' ); public function onBeforeWrite() { $this->owner->URLSegment = singleton('SiteTree')->generateURLSegment($this->owner->Title); } public function getLink() { $link = $this->owner->URLSegment; if (!$link) { //if no link has been generated, auto generate it $this->owner->write(); $link = $this->owner->URLSegment; } return $link; } // function getName() { // $name = $this->owner->Title; // return $name; // } } |