Source of file NewsPage.php
Size: 1,465 Bytes - Last Modified: 2021-12-24T06:49:03+00:00
/var/www/docs.ssmods.com/process/src/code/pagetypes/NewsPage.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 | <?php class NewsPage extends Page { public static $default_parent = 'NewsHolderPage'; public static $can_be_root = false; public static $icon = "silverstripe-gdm-express/assets/images/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 { } |