From a2fe3bed625a61ccf6496fceed4561f1c65ec529 Mon Sep 17 00:00:00 2001 From: merdan Date: Fri, 21 May 2021 18:27:57 +0500 Subject: [PATCH] opengraph --- plugins/rainlab/blog/components/Posts.php | 7 +++++++ plugins/rainlab/blog/models/Post.php | 6 +++++- themes/modern2/pages/index.htm | 1 - themes/modern2/partials/slider.htm | 13 +++++++++++-- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/plugins/rainlab/blog/components/Posts.php b/plugins/rainlab/blog/components/Posts.php index 22e507b7b..85ff2f953 100644 --- a/plugins/rainlab/blog/components/Posts.php +++ b/plugins/rainlab/blog/components/Posts.php @@ -85,6 +85,12 @@ class Posts extends ComponentBase 'type' => 'string', 'default' => '', ], + 'featured' => [ + 'title' => 'Featured posts', + 'description' => 'Filter featured posts', + 'type' => 'checkbox', + + ], 'postsPerPage' => [ 'title' => 'rainlab.blog::lang.settings.posts_per_page', 'type' => 'string', @@ -206,6 +212,7 @@ class Posts extends ComponentBase 'page' => $this->property('pageNumber'), 'sort' => $this->property('sortOrder'), 'perPage' => $this->property('postsPerPage'), + 'featured' => $this->property('featured'), 'search' => trim(input('q')), 'category' => $category, 'date' => input('date'), diff --git a/plugins/rainlab/blog/models/Post.php b/plugins/rainlab/blog/models/Post.php index 74039109d..4c74fb2f4 100644 --- a/plugins/rainlab/blog/models/Post.php +++ b/plugins/rainlab/blog/models/Post.php @@ -272,7 +272,8 @@ class Post extends Model 'date' => '', 'published' => true, 'exceptPost' => null, - 'select' => null + 'select' => null, + 'featured' => null ], $options)); $searchableFields = ['title', 'slug', 'excerpt']; @@ -281,6 +282,9 @@ class Post extends Model $query->isPublished(); } + if($featured){ + $query-> where('featured',1); + } $date = trim($date); if(strtotime($date)){ diff --git a/themes/modern2/pages/index.htm b/themes/modern2/pages/index.htm index 92a12d23f..f6f11e19f 100644 --- a/themes/modern2/pages/index.htm +++ b/themes/modern2/pages/index.htm @@ -56,7 +56,6 @@ random = 0
- {% partial 'slider' %}
diff --git a/themes/modern2/partials/slider.htm b/themes/modern2/partials/slider.htm index 7b369beb1..ad55722ae 100644 --- a/themes/modern2/partials/slider.htm +++ b/themes/modern2/partials/slider.htm @@ -7,12 +7,21 @@ noPostsMessage = "No posts found" sortOrder = "published_at desc" categoryPage = "category" postPage = "post" + +[blogPosts featuredPosts] +pageNumber = "{{ :page }}" +postsPerPage = 8 +noPostsMessage = "No posts found" +sortOrder = "published_at desc" +categoryPage = "category" +postPage = "post" +featured = 1 ==
- Главное + {{'Главное'|_}} -
{% for post in posts %} {{post.title}} {% endfor %}
+
{% for post in featuredPosts %} {{post.title}} {% endfor %}