Source of file NewsHolder.php
Size: 1,686 Bytes - Last Modified: 2021-12-23T10:30:10+00:00
/var/www/docs.ssmods.com/process/src/code/pagetypes/NewsHolder.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 | <?php class NewsHolder extends Page { public static $allowed_children = array('NewsPage'); public static $default_child = 'NewsPage'; public static $icon = "themes/express/images/icons/sitetree_images/news_listing.png"; public $pageIcon = "images/icons/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(); } } |