MINOR: avoid current blog post being included in the recent posts widget

This commit is contained in:
Peter Thaleikis 2019-04-10 18:22:15 +07:00 committed by Robbie Averill
parent 1d775aa664
commit 078c877cbb

View File

@ -3,6 +3,7 @@
namespace SilverStripe\Blog\Widgets; namespace SilverStripe\Blog\Widgets;
use SilverStripe\Blog\Model\Blog; use SilverStripe\Blog\Model\Blog;
use SilverStripe\Control\Director;
use SilverStripe\Forms\DropdownField; use SilverStripe\Forms\DropdownField;
use SilverStripe\Forms\FieldList; use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\NumericField; use SilverStripe\Forms\NumericField;
@ -81,6 +82,7 @@ class BlogRecentPostsWidget extends Widget
if ($blog) { if ($blog) {
return $blog->getBlogPosts() return $blog->getBlogPosts()
->filter('ID:not', Director::get_current_page()->ID)
->sort('"PublishDate" DESC') ->sort('"PublishDate" DESC')
->limit($this->NumberOfPosts); ->limit($this->NumberOfPosts);
} }