public function BlogArchives() { if ($newsIndex = $this->NewsIndex()) { $alRet = new ArrayList(); $strPattern = SiteConfig::current_site_config()->ArchivePattern ?: '%Y, %M'; $iLimit = SiteConfig::current_site_config()->NumberOfArchives ?: PHP_INT_MAX; $strTable = Versioned::current_stage() == 'Stage' ? 'NewsPost' : 'NewsPost_Live'; $results = DB::query('SELECT DATE_FORMAT(`DateTime`, \'' . $strPattern . '\') AS Date FROM ' . $strTable . ' WHERE `DateTime` IS NOT NULL GROUP BY Date ORDER BY `DateTime` DESC LIMIT ' . $iLimit); while ($row = $results->nextRecord()) { $alRet->push(new ArrayData(array('Link' => $newsIndex->Link('archive/' . urlencode($row['Date'])), 'Archive' => $row['Date'], 'List' => NewsPost::get()->where('DATE_FORMAT(`DateTime`, \'' . $strPattern . '\') = \'' . $row['Date'] . '\'')))); } return $alRet; } }
public function NextNewsItem() { return NewsPost::get()->filter(array('DateTime:GreaterThanOrEqual' => $this->DateTime))->exclude('ID', $this->ID)->sort('DateTime')->first(); }
/** * RSS feed */ public function rss() { $list = NewsPost::get()->filter('ParentID', $this->ID); $list = $list->Sort('DateTime DESC'); $this->extend('updateRSSItems', $list); $feed = new RSSFeed($list, $this->AbsoluteLink(), $this->Title); return $feed->outputToBrowser(); }