From 2a8ebbbe8ec7fbec4a0a61895856686d4f787b06 Mon Sep 17 00:00:00 2001 From: merdan Date: Mon, 11 Oct 2021 13:16:01 +0500 Subject: [PATCH] rss yandex except obyavlenie --- plugins/rainlab/blog/components/RssFeed.php | 24 +++++++++++++++------ themes/modern2/pages/rss.htm | 3 ++- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/plugins/rainlab/blog/components/RssFeed.php b/plugins/rainlab/blog/components/RssFeed.php index e21f3a746..49bf971de 100644 --- a/plugins/rainlab/blog/components/RssFeed.php +++ b/plugins/rainlab/blog/components/RssFeed.php @@ -82,15 +82,24 @@ class RssFeed extends ComponentBase 'title' => 'Source', 'description' => 'Source google, yandex', 'type' => 'dropdown', - 'default' => 'google', + 'default' => 'google', + ], + 'exceptCategories' => [ + 'title' => 'rainlab.blog::lang.settings.posts_except_categories', + 'description' => 'rainlab.blog::lang.settings.posts_except_categories_description', + 'type' => 'string', + 'validationPattern' => '^[a-z0-9\-_,\s]+$', + 'validationMessage' => 'rainlab.blog::lang.settings.posts_except_categories_validation', + 'default' => '', + 'group' => 'rainlab.blog::lang.settings.group_exceptions', ] ]; } public function getSourceOptions(){ - return ['google'=>'google','yandex'=>'yandex']; + return ['google'=>'google','yandex'=>'yandex']; } - + public function getBlogPageOptions() { return Page::sortBy('baseFileName')->lists('baseFileName', 'baseFileName'); @@ -132,7 +141,7 @@ $this->page['language'] = \App::getLocale(); $this->page['rssLink'] = $this->currentPageUrl(); //Carbon::setLocale('en'); - + } protected function listPosts() @@ -142,10 +151,13 @@ $this->page['language'] = \App::getLocale(); /* * List all the posts, eager load their categories */ - $posts = BlogPost::with('categories')->listFrontEnd([ + $posts = BlogPost::listFrontEnd([ 'sort' => $this->property('sortOrder'), 'perPage' => $this->property('postsPerPage'), - 'category' => $category + 'category' => $category, + 'exceptCategories' => is_array($this->property('exceptCategories')) + ? $this->property('exceptCategories') + : preg_split('/,\s*/', $this->property('exceptCategories'), -1, PREG_SPLIT_NO_EMPTY), ]); /* diff --git a/themes/modern2/pages/rss.htm b/themes/modern2/pages/rss.htm index 5f75b563e..83e4526ab 100644 --- a/themes/modern2/pages/rss.htm +++ b/themes/modern2/pages/rss.htm @@ -20,4 +20,5 @@ postsPerPage = 20 blogPage = "index" postPage = "post" source = "yandex" -== \ No newline at end of file +exceptCategories = "obyavlenie" +==