Source of file LatestnewsWidget.php
Size: 1,579 Bytes - Last Modified: 2021-12-24T06:47:36+00:00
/var/www/docs.ssmods.com/process/src/code/widgets/LatestnewsWidget.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 | <?php /** * The LatestNews widget to be globally used. * * Requires the Widgets module. * * @package Silverstripe * @subpackage Newsmodule * @author Simon 'Sphere' Erkelens */ /** Only if the Widget module is installed, add this widget. */ if (class_exists('Widget')) { class LatestnewsWidget extends Widget { /** * @var array */ private static $db = array( 'WidgetTitle' => 'Varchar(255)', 'Amount' => 'Int' ); /** * @var array */ private static $defaults = array( 'WidgetTitle' => 'Latest news', ); /** * @var string */ private static $cmsTitle = 'News widget'; /** * @var string */ private static $description = 'Widget showing the latest newsitems'; /** * @return mixed */ public function getCMSFields() { /** @var FieldList $fields */ $fields = FieldList::create(); $fields->push(TextField::create('WidgetTitle', 'Title of this widget')); $fields->push(TextField::create('Amount', 'Amount of items to show')); return $fields; } /** * @return mixed */ public function latestNews() { return Controller::curr()->NewsArchive($this->Amount); } /** * @return mixed */ public function Title() { return $this->WidgetTitle; } } } |