Merge pull request #577 from SpeksForks/exclude-current-post-in-recent-widget

MINOR: avoid current blog post being included in the recent posts widget
This commit is contained in:
Robbie Averill 2019-04-10 23:42:31 +12:00 committed by GitHub
commit 1c42689290
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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