1. Only in the news pages do they work (using ArticlePage).
2. Publications and Events the paging does not show at all (again using ArticlePage).
Code ArticlePage.php:
<?php
/**
* Defines the ArticlePage page type
*/
class ArticlePage extends Page {
static $db = array(
'Date' => 'Date',
'Author' => 'Text',
);
static $has_one = array(
);
static $icon = "themes/tutorial/images/treeicons/news";
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Main', new TextField('Author'), 'Content');
// $fields->addFieldToTab('Root.Content.Main', new DateField('Date'), 'Content');
$datefield = new DateField('Date');
$datefield->setConfig('showcalendar', true);
$datefield->setConfig('showdropdown', true);
$datefield->setConfig('dateformat', 'dd/MM/YYYY');
$fields->addFieldToTab('Root.Content.Main', $datefield, 'Content');
return $fields;
}
}
class ArticlePage_Controller extends Page_Controller {
function LatestNews($num=3) {
$news = DataObject::get_one("NewsHolder");
return ($news) ? DataObject::get("ArticlePage", "ParentID = $news->ID", "Date DESC", "", $num) : false;
}
// ************ Previous or Next Buttons *************
public function nextPager() {
$where = "ParentID = ($this->ParentID + 0) AND Sort > ($this->Sort + 0 )";
$pages = DataObject::get("SiteTree", $where, "Sort", "", 1);
if($pages) {
foreach($pages as $page) {
return $page;
}
}
}
public function previousPager() {
$where = "ParentID = ($this->ParentID + 0) AND Sort < ($this->Sort + 0)";
$pages = DataObject::get("SiteTree", $where, "Sort DESC", "", 1);
if($pages) {
foreach($pages as $page) {
return $page;
}
}
}
}
?>
ArticlePage.ss
<div class="paging">
<% if previousPager %>
<p class="previous"><a href="$previousPager.URLSegment">Previous</a></p>
<% end_if %>
<% if nextPager %>
<p class="next"><a href="$nextPager.URLSegment">Next</a></p>
<% end_if %>
</div>
Many thanks.