Source of file NewsPage.php
Size: 1,482 Bytes - Last Modified: 2021-12-23T10:30:10+00:00
/var/www/docs.ssmods.com/process/src/code/pagetypes/NewsPage.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 | <?php class NewsPage extends Page { public static $default_parent = 'NewsHolderPage'; public static $can_be_root = false; public static $icon = "themes/express/images/icons/sitetree_images/news.png"; public $pageIcon = "images/icons/sitetree_images/news.png"; public static $db = array( 'Date' => 'SS_Datetime', 'Abstract' => 'Text', 'Author' => 'Varchar(255)' ); public static $has_one = array( 'Category' => 'NewsCategory' ); /** * Add the default for the Date being the current day. */ public function populateDefaults() { parent::populateDefaults(); if (!isset($this->Date) || $this->Date === null) { $this->Date = SS_Datetime::now()->Format('Y-m-d H:i:s'); } } public function getCMSFields() { $fields = parent::getCMSFields(); $fields->addFieldToTab('Root.Main', $dateTimeField = new DatetimeField('Date'), 'Content'); $dateTimeField->getDateField()->setConfig('showcalendar', true); $categories = NewsCategory::get()->sort('Title ASC'); if ($categories && $categories->exists()) { $fields->addFieldToTab('Root.Main', new DropdownField('CategoryID', 'Category', $categories->map()), 'Content'); } $fields->addFieldToTab('Root.Main', new TextareaField('Abstract'), 'Content'); return $fields; } } class NewsPage_Controller extends Page_Controller { } |