From 8dc2d24b1e38d7d4bd2c764b771e0d0e08f5b3ac Mon Sep 17 00:00:00 2001 From: "ivan.hrytsai" Date: Wed, 18 Sep 2024 16:34:06 +0300 Subject: [PATCH 1/6] initial commit --- Block/Search/PostList.php | 18 ++++++- Controller/Search/Index.php | 1 + etc/adminhtml/system.xml | 28 +++++++++++ etc/config.xml | 4 ++ view/frontend/layout/blog_default.xml | 6 ++- view/frontend/templates/sidebar/search.phtml | 49 +++++++++++++++++++- 6 files changed, 102 insertions(+), 4 deletions(-) diff --git a/Block/Search/PostList.php b/Block/Search/PostList.php index fe1e5843..ce3e4d82 100755 --- a/Block/Search/PostList.php +++ b/Block/Search/PostList.php @@ -15,6 +15,22 @@ */ class PostList extends \Magefan\Blog\Block\Post\PostList { + + public function __construct( + \Magento\Framework\View\Element\Template\Context $context, + \Magento\Framework\Registry $coreRegistry, + \Magento\Cms\Model\Template\FilterProvider $filterProvider, + \Magefan\Blog\Model\ResourceModel\Post\CollectionFactory $postCollectionFactory, + \Magefan\Blog\Model\Url $url, + \Magento\Framework\Event\Manager $eventManager, + array $data = [], + $config = null, + $templatePool = null) + { + $this->eventManager = $eventManager; + parent::__construct($context, $coreRegistry, $filterProvider, $postCollectionFactory, $url,$data, $config, $templatePool); + } + /** * Retrieve query * @return string @@ -39,6 +55,7 @@ protected function _preparePostCollection() self::POSTS_SORT_FIELD_BY_PUBLISH_TIME, \Magento\Framework\Api\SortOrder::SORT_DESC ); + $this->eventManager->dispatch('blog_search_prepare_post_collection_after',['post_collection' => $this->_postCollection]); } /** @@ -80,7 +97,6 @@ protected function _prepareLayout() $this->escapeHtml($title) ); } - return parent::_prepareLayout(); } diff --git a/Controller/Search/Index.php b/Controller/Search/Index.php index aca195ab..e50e4820 100755 --- a/Controller/Search/Index.php +++ b/Controller/Search/Index.php @@ -19,6 +19,7 @@ class Index extends \Magefan\Blog\App\Action\Action */ public function execute() { + var_dump($this->getRequest()->getParams()); if (!$this->moduleEnabled()) { return $this->_forwardNoroute(); } diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 64427e1d..c6602096 100755 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -520,6 +520,19 @@ + + + + Magento\Config\Model\Config\Source\Yesno + + + + Magefan\BlogExtra\Model\Config\Source\AvailableFilters + + 1 + + + @@ -1040,6 +1053,21 @@ Magento\Config\Model\Config\Source\Yesno + + + Magento\Config\Model\Config\Source\Yesno + + 1 + + + + + Magefan\BlogExtra\Model\Config\Source\AvailableFilters + + 1 + 1 + + diff --git a/etc/config.xml b/etc/config.xml index 1c9e0637..066c0302 100755 --- a/etc/config.xml +++ b/etc/config.xml @@ -127,12 +127,16 @@ 0 + 0 + category,author,tag,publication_date 1 10 + 0 + category,author,tag,publication_date 1 diff --git a/view/frontend/layout/blog_default.xml b/view/frontend/layout/blog_default.xml index 8c1c928c..1684abf3 100755 --- a/view/frontend/layout/blog_default.xml +++ b/view/frontend/layout/blog_default.xml @@ -16,7 +16,11 @@ - + + + + + 86400 diff --git a/view/frontend/templates/sidebar/search.phtml b/view/frontend/templates/sidebar/search.phtml index 0b0850cf..711b076b 100755 --- a/view/frontend/templates/sidebar/search.phtml +++ b/view/frontend/templates/sidebar/search.phtml @@ -15,6 +15,43 @@ */ ?> + +
@@ -44,22 +82,29 @@ escapeHtml(__('Search')) ?>
+ + renderTag('script', [], $script, false) ?> From 46c66ea69f72b142a2f1973400c413f8c5d202ca Mon Sep 17 00:00:00 2001 From: "ivan.hrytsai" Date: Thu, 19 Sep 2024 14:09:19 +0300 Subject: [PATCH 2/6] 11681-Blog-Search-Filter-Option --- .../System/Config/Form/InfoBlogExtra.php | 4 +- Controller/Search/Index.php | 1 - etc/adminhtml/system.xml | 1 + view/frontend/templates/sidebar/search.phtml | 43 +------------------ 4 files changed, 5 insertions(+), 44 deletions(-) diff --git a/Block/Adminhtml/System/Config/Form/InfoBlogExtra.php b/Block/Adminhtml/System/Config/Form/InfoBlogExtra.php index 450920ed..77ce8e3f 100644 --- a/Block/Adminhtml/System/Config/Form/InfoBlogExtra.php +++ b/Block/Adminhtml/System/Config/Form/InfoBlogExtra.php @@ -34,7 +34,9 @@ protected function getSectionsJson(): string 'mfblog_post_view_comments_admin_send_to', 'mfblog_post_view_comments_admin_email_template', 'mfblog_blog_search', - 'mfblog_sidebar_contents' + 'mfblog_sidebar_contents', + 'mfblog_sidebar_search_display_filters', + 'mfblog_sidebar_search_available_filters' ]); return $sections; } diff --git a/Controller/Search/Index.php b/Controller/Search/Index.php index e50e4820..aca195ab 100755 --- a/Controller/Search/Index.php +++ b/Controller/Search/Index.php @@ -19,7 +19,6 @@ class Index extends \Magefan\Blog\App\Action\Action */ public function execute() { - var_dump($this->getRequest()->getParams()); if (!$this->moduleEnabled()) { return $this->_forwardNoroute(); } diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index c6602096..d596a1de 100755 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -529,6 +529,7 @@ Magefan\BlogExtra\Model\Config\Source\AvailableFilters + 1 1 diff --git a/view/frontend/templates/sidebar/search.phtml b/view/frontend/templates/sidebar/search.phtml index 711b076b..7fa4a4e3 100755 --- a/view/frontend/templates/sidebar/search.phtml +++ b/view/frontend/templates/sidebar/search.phtml @@ -15,43 +15,6 @@ */ ?> - - - + Date: Fri, 20 Sep 2024 10:58:53 +0300 Subject: [PATCH 3/6] Update blog_default.xml --- view/frontend/layout/blog_default.xml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/view/frontend/layout/blog_default.xml b/view/frontend/layout/blog_default.xml index 1684abf3..434a2ad0 100755 --- a/view/frontend/layout/blog_default.xml +++ b/view/frontend/layout/blog_default.xml @@ -16,11 +16,9 @@ - - + - 86400 From 95740ab0c1b3c88925270f722b5363cbe990a8bb Mon Sep 17 00:00:00 2001 From: Magefan Date: Fri, 20 Sep 2024 10:59:43 +0300 Subject: [PATCH 4/6] Update search.phtml --- view/frontend/templates/sidebar/search.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/frontend/templates/sidebar/search.phtml b/view/frontend/templates/sidebar/search.phtml index 7fa4a4e3..2392c225 100755 --- a/view/frontend/templates/sidebar/search.phtml +++ b/view/frontend/templates/sidebar/search.phtml @@ -35,7 +35,7 @@ aria-haspopup="false" aria-autocomplete="both" autocomplete="off"> - getChildHtml('blog_sidebar_search_filters') ?> + getChildHtml('form_additional') ?>
From 881e0d1d8d678590921a7f014186e0014212b79e Mon Sep 17 00:00:00 2001 From: "ivan.hrytsai" Date: Fri, 20 Sep 2024 15:13:52 +0300 Subject: [PATCH 5/6] fix for previous commit --- Block/Search/PostList.php | 17 +---------------- view/frontend/templates/sidebar/search.phtml | 15 ++++++++------- 2 files changed, 9 insertions(+), 23 deletions(-) diff --git a/Block/Search/PostList.php b/Block/Search/PostList.php index ce3e4d82..2f8c2072 100755 --- a/Block/Search/PostList.php +++ b/Block/Search/PostList.php @@ -16,21 +16,6 @@ class PostList extends \Magefan\Blog\Block\Post\PostList { - public function __construct( - \Magento\Framework\View\Element\Template\Context $context, - \Magento\Framework\Registry $coreRegistry, - \Magento\Cms\Model\Template\FilterProvider $filterProvider, - \Magefan\Blog\Model\ResourceModel\Post\CollectionFactory $postCollectionFactory, - \Magefan\Blog\Model\Url $url, - \Magento\Framework\Event\Manager $eventManager, - array $data = [], - $config = null, - $templatePool = null) - { - $this->eventManager = $eventManager; - parent::__construct($context, $coreRegistry, $filterProvider, $postCollectionFactory, $url,$data, $config, $templatePool); - } - /** * Retrieve query * @return string @@ -55,7 +40,7 @@ protected function _preparePostCollection() self::POSTS_SORT_FIELD_BY_PUBLISH_TIME, \Magento\Framework\Api\SortOrder::SORT_DESC ); - $this->eventManager->dispatch('blog_search_prepare_post_collection_after',['post_collection' => $this->_postCollection]); + $this->_eventManager->dispatch('blog_search_prepare_post_collection_after', ['post_collection' => $this->_postCollection]); } /** diff --git a/view/frontend/templates/sidebar/search.phtml b/view/frontend/templates/sidebar/search.phtml index 2392c225..4247a485 100755 --- a/view/frontend/templates/sidebar/search.phtml +++ b/view/frontend/templates/sidebar/search.phtml @@ -24,7 +24,7 @@ -
+
renderTag('script', [], $script, false) ?> From 94f540413f0f0191d8f3d5b7e9ad7cdfacab7c6d Mon Sep 17 00:00:00 2001 From: "ivan.hrytsai" Date: Mon, 23 Sep 2024 14:49:29 +0300 Subject: [PATCH 6/6] move Config Source to base --- Model/Config/Source/AvailableFilters.php | 43 ++++++++++++++++++++++++ etc/adminhtml/system.xml | 4 +-- 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 Model/Config/Source/AvailableFilters.php diff --git a/Model/Config/Source/AvailableFilters.php b/Model/Config/Source/AvailableFilters.php new file mode 100644 index 00000000..20da6ea2 --- /dev/null +++ b/Model/Config/Source/AvailableFilters.php @@ -0,0 +1,43 @@ + 'category', 'label' => __('Category')], + ['value' => 'author', 'label' => __('Author')], + ['value' => 'tag', 'label' => __('Tag')], + ['value' => 'publication_date', 'label' => __('Publication Date (From/To)')] + ]; + } + + + /** + * Get options in "key-value" format + * + * @return array + */ + public function toArray() + { + $array = []; + foreach ($this->toOptionArray() as $item) { + $array[$item['value']] = $item['label']; + } + return $array; + } +} \ No newline at end of file diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index d596a1de..ef3e3615 100755 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -527,7 +527,7 @@ - Magefan\BlogExtra\Model\Config\Source\AvailableFilters + Magefan\Blog\Model\Config\Source\AvailableFilters 1 1 @@ -1063,7 +1063,7 @@ - Magefan\BlogExtra\Model\Config\Source\AvailableFilters + Magefan\Blog\Model\Config\Source\AvailableFilters 1 1