Source of file NewsHolder.php
Size: 1,756 Bytes - Last Modified: 2021-12-24T06:49:03+00:00
/var/www/docs.ssmods.com/process/src/code/pagetypes/NewsHolder.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 | <?php class NewsHolder extends Page { public static $allowed_children = array('NewsPage'); public static $default_child = 'NewsPage'; public static $icon = "silverstripe-gdm-express/assets/images/sitetree_images/news_listing.png"; public $pageIcon = "silverstripe-gdm-express/assets/images/sitetree_images/news_listing.png"; public function MenuChildren() { return parent::MenuChildren()->exclude('ClassName', 'NewsPage'); } public function getCategories() { return NewsCategory::get()->sort('Title', 'DESC'); } public function getDefaultRSSLink() { return $this->Link('rss'); } } class NewsHolder_Controller extends Page_Controller { public function init() { parent::init(); RSSFeed::linkToFeed($this->Link() . 'rss', SiteConfig::current_site_config()->Title . ' news'); } public function getNewsItems($pageSize = 10) { $items = DataObject::get('NewsPage', "ParentID = $this->ID")->sort('Date', 'DESC'); $category = $this->getCategory(); if ($category) { $items = $items->filter('CategoryID', $category->ID); } $list = new PaginatedList($items, $this->request); $list->setPageLength($pageSize); return $list; } public function getCategory() { $categoryID = $this->request->getVar('category'); if (!is_null($categoryID)) { return NewsCategory::get_by_id('NewsCategory', $categoryID); } } public function rss() { $rss = new RSSFeed($this->Children(), $this->Link, SiteConfig::current_site_config()->Title . ' news'); return $rss->outputToBrowser(); } } |