FEATURE: added NextBlogEntry() and PreviousBlogEntry() functions to allow getting the next / previous posts by date in the template using $NextBlogEntry and $PreviousBlogEntry respectively

This commit is contained in:
Will Rossiter 2010-05-16 01:10:24 +00:00
parent aebe342ddd
commit 3864a78ab5
1 changed files with 30 additions and 0 deletions

View File

@ -188,9 +188,39 @@ class BlogEntry extends Page {
static function allow_wysiwyg_editing() {
self::$allow_wysiwyg_editing = true;
}
/**
* Get the previous blog entry from this section of blog pages.
*
* @return BlogEntry
*/
function PreviousBlogEntry() {
return DataObject::get_one(
'BlogEntry',
"\"SiteTree\".\"ParentID\" = '$this->ParentID' AND \"BlogEntry\".\"Date\" < '$this->Date'",
true,
'Date DESC'
);
}
/**
* Get the next blog entry from this section of blog pages.
*
* @return BlogEntry
*/
function NextBlogEntry() {
return DataObject::get_one(
'BlogEntry',
"\"SiteTree\".\"ParentID\" = '$this->ParentID' AND \"BlogEntry\".\"Date\" > '$this->Date'",
true,
'Date ASC'
);
}
}
class BlogEntry_Controller extends Page_Controller {
static $allowed_actions = array(
'index',
'trackbackping',