mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
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:
parent
aebe342ddd
commit
3864a78ab5
@ -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',
|
||||
|
Loading…
Reference in New Issue
Block a user