/** * Add implementors token which is csv of 'nice' names of implementors of HasRelatedPages relationship. * @return mixed */ public function fieldDecorationTokens() { $implementors = HasRelatedPages::implementors(); $titles = []; /** @var \Page $page */ $page = $this(); foreach ($implementors as $className => $title) { $relationshipName = $className::relationship_name(); if ($page->hasRelationship($relationshipName)) { $titles[] = $title; } } return array_merge(parent::fieldDecorationTokens(), ['implementors' => implode(', ', $titles ?: ['None found on this page type '])]); }
public function fieldDecorationTokens() { return array_merge(parent::fieldDecorationTokens(), ['modelTag' => $this->singleFieldValue()]); }
/** * Add the model tag of the current page so can use in decoration for enable/disable field. * * @return mixed */ public function fieldDecorationTokens() { return array_merge(parent::fieldDecorationTokens(), ['modelTag' => \Director::get_current_page()->{ModelTag::SingleFieldName}]); }