Source of file ExplanationPage.php
Size: 1,264 Bytes - Last Modified: 2021-12-23T10:59:27+00:00
/var/www/docs.ssmods.com/process/src/code/pages/ExplanationPage.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 | <?php class ExplanationPage extends Page { public static $has_many = array( 'Explanations' => 'Explanation' ); public function getCMSFields() { $fields = parent::getCMSFields(); $conf = GridFieldConfig_RecordEditor::create(); $grid = GridField::create('Explanations', $this->fieldLabel('Explanations'), $this->Explanations(), $conf); $tabTitle = $this->fieldLabel('Explanations'); $fields->addFieldsToTab('Root.' . $tabTitle, $grid); return $fields; } } class ExplanationPage_Controller extends AbbreviationPage_Controller { private static $url_handlers = array( '$Item!' => 'viewItem' ); private static $allowed_actions = array( 'viewItem' ); public function viewItem() { $item = $this->getItem($this->request->param('Item')); if (!$item) { $this->httpError(404); } return $this->customise(array('Item' => $item))->renderWith(array('ExplanationPage_view', 'Page')); } public function getItem($slug) { return Explanation::get()->filter(array('URLSlug' => $slug))->first(); } public function getItems() { return Explanation::get()->sort('Title'); } } |