From 860e11deed0dbb9a48f2cb4ea9a052dc974b4ea3 Mon Sep 17 00:00:00 2001 From: Bogdan Kitura Date: Tue, 22 Apr 2025 13:15:20 +0200 Subject: [PATCH 1/8] 13277-new-design-magefan-blog --- .../System/Config/Form/InfoBlogExtra.php | 3 +- Block/Post/PostList.php | 58 ++++++++++++++++++- Model/Config/Source/DesignVersion.php | 42 ++++++++++++++ Model/Config/Source/Template.php | 7 +++ etc/adminhtml/system.xml | 44 ++++++++++++++ etc/di.xml | 5 ++ 6 files changed, 155 insertions(+), 4 deletions(-) create mode 100644 Model/Config/Source/DesignVersion.php diff --git a/Block/Adminhtml/System/Config/Form/InfoBlogExtra.php b/Block/Adminhtml/System/Config/Form/InfoBlogExtra.php index bdcb11a8..e74bdf36 100644 --- a/Block/Adminhtml/System/Config/Form/InfoBlogExtra.php +++ b/Block/Adminhtml/System/Config/Form/InfoBlogExtra.php @@ -37,7 +37,8 @@ protected function getSectionsJson(): string 'mfblog_blog_search', 'mfblog_sidebar_contents', 'mfblog_ai_writer', - 'mfblog_draft_autosave' + 'mfblog_draft_autosave', + 'mfblog_developer_version' ]); return $sections; } diff --git a/Block/Post/PostList.php b/Block/Post/PostList.php index 1fbdbb8e..08a53db8 100755 --- a/Block/Post/PostList.php +++ b/Block/Post/PostList.php @@ -26,6 +26,10 @@ class PostList extends \Magefan\Blog\Block\Post\PostList\AbstractList */ protected $toolbarBlock; + /** + * @var + */ + protected $templateType ; /** * Preparing global layout * @@ -73,10 +77,26 @@ public function getPostHtml($post) */ public function getTemplate() { - if (!in_array($this->_template, ['post/list.phtml', 'Magefan_Blog::post/list.phtml'])) { - /* If template was not customized in layout */ + /*if ($this->_scopeConfig->getValue('mfblog/developer/version', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE) == '2025-04') { + $this->_template = 'Magefan_BlogExtra::post/article.phtml'; + + if (!empty($this->templatePool->getAll('blog_post_list_new')[$this->getPostTemplateType()])) { + $this->setNewDesignType($this->getPostTemplateType()); + } else { + $this->setNewDesignType( + $this->_scopeConfig->getValue('mfblog/post_list/templates_new', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE) + ); + } return parent::getTemplate(); - } + }*/ + + if (!in_array($this->_template, ['post/list.phtml', 'Magefan_Blog::post/list.phtml'])) { + /* If template was not customized in layout */ + return parent::getTemplate(); + } + if ($template = $this->templatePool->getTemplate('blog_post_list', $this->getPostTemplateType())) { $this->_template = $template; @@ -197,4 +217,36 @@ protected function getBreadcrumbsBlock() { return $this->getLayout()->getBlock('breadcrumbs'); } + + /** + * Set template type for new design + * + * @return mixed + */ + public function getNewDesignType() { + if (!$this->templateType) { + if (!empty($this->templatePool->getAll('blog_post_list_new')[$this->getPostTemplateType()])) { + $this->setNewDesignType($this->getPostTemplateType()); + } else { + $this->setNewDesignType( + $this->_scopeConfig->getValue('mfblog/post_list/templates_new', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE) + ); + } + } + + return $this->templateType; + } + + /** + * Get template type for new design + * + * @param $templateType + * @return $this + */ + public function setNewDesignType($templateType) { + $this->templateType = $templateType; + return $this; + } + } diff --git a/Model/Config/Source/DesignVersion.php b/Model/Config/Source/DesignVersion.php new file mode 100644 index 00000000..597e1665 --- /dev/null +++ b/Model/Config/Source/DesignVersion.php @@ -0,0 +1,42 @@ + '2024-12', 'label' => '2024-12'], + ['value' => '2025-04', 'label' => '2025-04'] + ]; + } + + /** + * Get options in "key-value" format + * + * @return array + */ + public function toArray() + { + $array = []; + foreach ($this->toOptionArray() as $item) { + $array[$item['value']] = $item['label']; + } + return $array; + } +} diff --git a/Model/Config/Source/Template.php b/Model/Config/Source/Template.php index 7fb47943..e19080f0 100644 --- a/Model/Config/Source/Template.php +++ b/Model/Config/Source/Template.php @@ -52,6 +52,13 @@ public function toOptionArray():array if (!$this->templateType) { return[]; } + $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); + $config = $objectManager->get(\Magefan\Blog\Model\Config::class); + + if ($this->templateType == 'blog_post_list' && ($config->getConfig('mfblog/developer/version') == '2025-04')) { + $this->templateType = 'blog_post_list_new'; + } + if (!isset($this->options[$this->templateType])) { $this->options[$this->templateType] = []; foreach ($this->templatePool->getAll($this->templateType) as $value => $info) { diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 214c1397..806867a6 100755 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -97,6 +97,16 @@ Magefan\Blog\Model\Config\Source\PostListTemplate + + 2024-12 + + + + + Magefan\Blog\Model\Config\Source\PostListTemplateNew + + 2025-04 + @@ -433,6 +443,16 @@ Magefan\Blog\Model\Config\Source\PostListTemplate + + 2024-12 + + + + + Magefan\Blog\Model\Config\Source\PostListTemplateNew + + 2025-04 + @@ -481,6 +501,15 @@ Magefan\Blog\Model\Config\Source\PostListTemplate 1 + 2024-12 + + + + + Magefan\Blog\Model\Config\Source\PostListTemplateNew + + 1 + 2025-04 @@ -579,6 +608,16 @@ Magefan\Blog\Model\Config\Source\PostListTemplate + + 2024-12 + + + + + Magefan\Blog\Model\Config\Source\PostListTemplateNew + + 2025-04 + @@ -1165,6 +1204,11 @@ Magento\Config\Model\Config\Source\Yesno + + + Magefan\Blog\Model\Config\Source\DesignVersion + diff --git a/etc/di.xml b/etc/di.xml index ea279c8f..e23ef0fe 100755 --- a/etc/di.xml +++ b/etc/di.xml @@ -138,6 +138,11 @@ blog_post_list + + + blog_post_list_new + + blog_post_view From 4f776a0ff5331e0f6f1136926a0a453aec1e5887 Mon Sep 17 00:00:00 2001 From: Bogdan Kitura Date: Thu, 8 May 2025 10:32:32 +0200 Subject: [PATCH 2/8] 13277-new-design-magefan-blog [in progress] --- .../System/Config/Form/InfoBlogExtra.php | 2 +- Block/Author/PostList.php | 21 ++++- Block/Catalog/Product/RelatedPosts.php | 37 ++++++++ Block/Post/PostList.php | 51 ---------- Block/Post/PostList/AbstractList.php | 42 +++++++++ Block/Post/View/RelatedPosts.php | 36 ++++++++ Block/Sidebar/Featured.php | 41 ++++++++- Block/Sidebar/Popular.php | 36 +++++++- Block/Sidebar/Recent.php | 36 ++++++++ Block/Widget/Featured.php | 32 ++++++- Block/Widget/Recent.php | 37 +++++++- Model/Config/Source/Template.php | 4 +- etc/adminhtml/system.xml | 92 ++++++++++++++++--- etc/config.xml | 1 + etc/di.xml | 17 +++- etc/widget.xml | 46 +++++++++- .../post/view/comments/magefan.phtml | 35 +++---- view/frontend/web/css/blog-m.css | 1 + view/frontend/web/css/blog-new.css | 34 ++++++- view/frontend/web/css/comments.css | 17 ++-- 20 files changed, 514 insertions(+), 104 deletions(-) diff --git a/Block/Adminhtml/System/Config/Form/InfoBlogExtra.php b/Block/Adminhtml/System/Config/Form/InfoBlogExtra.php index e74bdf36..7e2be951 100644 --- a/Block/Adminhtml/System/Config/Form/InfoBlogExtra.php +++ b/Block/Adminhtml/System/Config/Form/InfoBlogExtra.php @@ -38,7 +38,7 @@ protected function getSectionsJson(): string 'mfblog_sidebar_contents', 'mfblog_ai_writer', 'mfblog_draft_autosave', - 'mfblog_developer_version' + 'mfblog_design_version' ]); return $sections; } diff --git a/Block/Author/PostList.php b/Block/Author/PostList.php index 8dbd563e..7d0c53aa 100755 --- a/Block/Author/PostList.php +++ b/Block/Author/PostList.php @@ -107,15 +107,30 @@ protected function _prepareLayout() */ public function getPostTemplateType() { + $designVersion = (string)$this->_scopeConfig->getValue( + 'mfblog/design/version', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); + + $template = (string)$this->getAuthor()->getData('posts_list_template'); + if (!empty($this->templatePool->getAll('blog_post_list' . ($designVersion == '2025-04' ? '_2025_04' : ''))[$template])) { + if ($template) { + return $template; + } + } $template = (string)$this->_scopeConfig->getValue( 'mfblog/author/template', \Magento\Store\Model\ScopeInterface::SCOPE_STORE ); - if ($template) { - return $template; + + + if ($designVersion == '2025-04') { + $template = $this->_scopeConfig->getValue( + 'mfblog/author/templates_new', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); } - $template = (string)$this->getAuthor()->getData('posts_list_template'); if ($template) { return $template; } diff --git a/Block/Catalog/Product/RelatedPosts.php b/Block/Catalog/Product/RelatedPosts.php index fe7474c1..e327e548 100755 --- a/Block/Catalog/Product/RelatedPosts.php +++ b/Block/Catalog/Product/RelatedPosts.php @@ -74,6 +74,20 @@ public function getProduct() return $this->getData('product'); } + /** + * @return string + */ + public function getBlockKey() { + return 'related-posts'; + } + + /** + * @return string + */ + public function getBlockTitle() { + return 'Related Posts'; + } + /** * Get relevant path to template * @@ -81,6 +95,29 @@ public function getProduct() */ public function getTemplate() { + $designVersion = (string)$this->_scopeConfig->getValue( + 'mfblog/design/version', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); + + if ($designVersion == '2025-04') { + $template = (string)$this->_scopeConfig->getValue( + 'mfblog/product_page/related_posts_template_new', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); + if ($template == 'default') { + return parent::getTemplate(); + } + if ($template == 'article-slider') { + return 'Magefan_BlogExtra::post/list/carousel-2025-04.phtml'; + } + if (strpos((string) parent::getTemplate(), 'article.phtml') !== false) { + return parent::getTemplate(); + } + + return 'Magefan_BlogExtra::post/view/post-bottom-2025-04.phtml'; + } + $templateName = (string)$this->_scopeConfig->getValue( 'mfblog/product_page/related_posts_template', \Magento\Store\Model\ScopeInterface::SCOPE_STORE diff --git a/Block/Post/PostList.php b/Block/Post/PostList.php index 08a53db8..bfde0577 100755 --- a/Block/Post/PostList.php +++ b/Block/Post/PostList.php @@ -26,10 +26,6 @@ class PostList extends \Magefan\Blog\Block\Post\PostList\AbstractList */ protected $toolbarBlock; - /** - * @var - */ - protected $templateType ; /** * Preparing global layout * @@ -77,21 +73,6 @@ public function getPostHtml($post) */ public function getTemplate() { - /*if ($this->_scopeConfig->getValue('mfblog/developer/version', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE) == '2025-04') { - $this->_template = 'Magefan_BlogExtra::post/article.phtml'; - - if (!empty($this->templatePool->getAll('blog_post_list_new')[$this->getPostTemplateType()])) { - $this->setNewDesignType($this->getPostTemplateType()); - } else { - $this->setNewDesignType( - $this->_scopeConfig->getValue('mfblog/post_list/templates_new', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE) - ); - } - return parent::getTemplate(); - }*/ - if (!in_array($this->_template, ['post/list.phtml', 'Magefan_Blog::post/list.phtml'])) { /* If template was not customized in layout */ return parent::getTemplate(); @@ -217,36 +198,4 @@ protected function getBreadcrumbsBlock() { return $this->getLayout()->getBlock('breadcrumbs'); } - - /** - * Set template type for new design - * - * @return mixed - */ - public function getNewDesignType() { - if (!$this->templateType) { - if (!empty($this->templatePool->getAll('blog_post_list_new')[$this->getPostTemplateType()])) { - $this->setNewDesignType($this->getPostTemplateType()); - } else { - $this->setNewDesignType( - $this->_scopeConfig->getValue('mfblog/post_list/templates_new', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE) - ); - } - } - - return $this->templateType; - } - - /** - * Get template type for new design - * - * @param $templateType - * @return $this - */ - public function setNewDesignType($templateType) { - $this->templateType = $templateType; - return $this; - } - } diff --git a/Block/Post/PostList/AbstractList.php b/Block/Post/PostList/AbstractList.php index 9284bd61..01b9c0b2 100755 --- a/Block/Post/PostList/AbstractList.php +++ b/Block/Post/PostList/AbstractList.php @@ -59,6 +59,11 @@ abstract class AbstractList extends Template implements IdentityInterface */ protected $templatePool; + /** + * @var + */ + protected $templateType ; + const POSTS_SORT_FIELD_BY_PUBLISH_TIME = 'main_table.publish_time'; const POSTS_SORT_FIELD_BY_POSITION = 'position'; const POSTS_SORT_FIELD_BY_TITLE = 'main_table.title'; @@ -277,4 +282,41 @@ public function readingTimeEnabled() \Magento\Store\Model\ScopeInterface::SCOPE_STORE ); } + + /** + * Set template type for new design + * + * @return mixed + */ + public function getNewDesignType() { + if (!$this->templateType) { + if (!empty($this->templatePool->getAll('blog_post_list_2025_04')[$this->getPostTemplateType()])) { + $this->setNewDesignType($this->getPostTemplateType()); + } else if ($this->getRequest()->getFullActionName() == 'blog_index_index') { + $this->setNewDesignType( + $this->_scopeConfig->getValue('mfblog/index_page/templates_new', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE) + ); + return $this->templateType; + } else { + $this->setNewDesignType( + $this->_scopeConfig->getValue('mfblog/post_list/templates_new', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE) + ); + } + } + + return $this->templateType; + } + + /** + * Get template type for new design + * + * @param $templateType + * @return $this + */ + public function setNewDesignType($templateType) { + $this->templateType = $templateType; + return $this; + } } diff --git a/Block/Post/View/RelatedPosts.php b/Block/Post/View/RelatedPosts.php index 68e49ecf..e6c63dd5 100755 --- a/Block/Post/View/RelatedPosts.php +++ b/Block/Post/View/RelatedPosts.php @@ -63,6 +63,18 @@ public function getPost() return $this->getData('post'); } + /** + * @return string + */ + public function getBlockTitle() { + return 'Related Posts'; + } + /** + * @return string + */ + public function getBlockKey() { + return 'related-post'; + } /** * Get relevant path to template * @@ -70,6 +82,30 @@ public function getPost() */ public function getTemplate() { + $designVersion = (string)$this->_scopeConfig->getValue( + 'mfblog/design/version', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); + + if ($designVersion == '2025-04') { + $template = (string)$this->_scopeConfig->getValue( + 'mfblog/post_view/related_posts/template_new', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); + + if (strpos((string) parent::getTemplate(), 'article.phtml') !== false) { + return parent::getTemplate(); + } + + if ($template == 'default') { + return parent::getTemplate(); + } + + if ($template = $this->templatePool->getTemplate('blog_post_view_related_post_2025_04', $template)) { + return $template; + } + } + $templateName = (string)$this->_scopeConfig->getValue( 'mfblog/post_view/related_posts/template', \Magento\Store\Model\ScopeInterface::SCOPE_STORE diff --git a/Block/Sidebar/Featured.php b/Block/Sidebar/Featured.php index 1e378d9f..d601d10d 100644 --- a/Block/Sidebar/Featured.php +++ b/Block/Sidebar/Featured.php @@ -61,19 +61,36 @@ protected function getPostIdsConfigValue() \Magento\Store\Model\ScopeInterface::SCOPE_STORE ); } - + public function getWidgetKey() { + return (string)$this->_widgetKey; + } /** * Retrieve true if display the post image is enabled in the config * @return bool */ public function getDisplayImage() { + $designVersion = (string)$this->_scopeConfig->getValue( + 'mfblog/design/version', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); + + if ($designVersion == '2025-04') { + return false; + } return (bool)$this->_scopeConfig->getValue( 'mfblog/sidebar/'.$this->_widgetKey.'/display_image', \Magento\Store\Model\ScopeInterface::SCOPE_STORE ); } + public function getClass() { + return (string)$this->_scopeConfig->getValue( + 'mfblog/sidebar/'.$this->_widgetKey.'/template_new', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); + } + /** * Get relevant path to template * @@ -81,13 +98,35 @@ public function getDisplayImage() */ public function getTemplate() { + $designVersion = (string)$this->_scopeConfig->getValue( + 'mfblog/design/version', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); + $templateName = (string)$this->_scopeConfig->getValue( 'mfblog/sidebar/'.$this->_widgetKey.'/template', \Magento\Store\Model\ScopeInterface::SCOPE_STORE ); + + if ($designVersion == '2025-04') { + $template = $this->_scopeConfig->getValue( + 'mfblog/sidebar/'.$this->_widgetKey.'/template_new', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); + if (strpos((string) parent::getTemplate(), 'article.phtml') !== false) { + return parent::getTemplate(); + } + if ($template == 'default') { + $templateName = 'modern'; + } else { + return 'Magefan_BlogExtra::sidebar/recent_2025_04.phtml'; + } + } + if ($template = $this->templatePool->getTemplate('blog_post_sidebar_posts', $templateName)) { $this->_template = $template; } + return parent::getTemplate(); } } diff --git a/Block/Sidebar/Popular.php b/Block/Sidebar/Popular.php index 6c3bc5ca..313714b2 100644 --- a/Block/Sidebar/Popular.php +++ b/Block/Sidebar/Popular.php @@ -50,12 +50,26 @@ public function getCollectionOrderField() */ public function getDisplayImage() { + $designVersion = (string)$this->_scopeConfig->getValue( + 'mfblog/design/version', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); + + if ($designVersion == '2025-04') { + return false; + } return (bool)$this->_scopeConfig->getValue( 'mfblog/sidebar/'.$this->_widgetKey.'/display_image', \Magento\Store\Model\ScopeInterface::SCOPE_STORE ); } - + + public function getClass() { + return (string)$this->_scopeConfig->getValue( + 'mfblog/sidebar/'.$this->_widgetKey.'/template_new', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); + } /** * Get relevant path to template * @@ -63,10 +77,30 @@ public function getDisplayImage() */ public function getTemplate() { + $designVersion = (string)$this->_scopeConfig->getValue( + 'mfblog/design/version', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); $templateName = (string)$this->_scopeConfig->getValue( 'mfblog/sidebar/'.$this->_widgetKey.'/template', \Magento\Store\Model\ScopeInterface::SCOPE_STORE ); + + if ($designVersion == '2025-04') { + $template = $this->_scopeConfig->getValue( + 'mfblog/sidebar/'.$this->_widgetKey.'/template_new', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); + if (strpos((string) parent::getTemplate(), 'article.phtml') !== false) { + return parent::getTemplate(); + } + if ($template == 'default') { + $templateName = 'modern'; + } else { + return 'Magefan_BlogExtra::sidebar/recent_2025_04.phtml'; + } + } + if ($template = $this->templatePool->getTemplate('blog_post_sidebar_posts', $templateName)) { $this->_template = $template; } diff --git a/Block/Sidebar/Recent.php b/Block/Sidebar/Recent.php index d5fa5656..2cc3c31d 100755 --- a/Block/Sidebar/Recent.php +++ b/Block/Sidebar/Recent.php @@ -51,12 +51,27 @@ protected function _preparePostCollection() */ public function getDisplayImage() { + $designVersion = (string)$this->_scopeConfig->getValue( + 'mfblog/design/version', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); + + if ($designVersion == '2025-04') { + return false; + } return (bool)$this->_scopeConfig->getValue( 'mfblog/sidebar/'.$this->_widgetKey.'/display_image', \Magento\Store\Model\ScopeInterface::SCOPE_STORE ); } + public function getClass() { + return (string)$this->_scopeConfig->getValue( + 'mfblog/sidebar/'.$this->_widgetKey.'/template_new', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); + } + /** * Get relevant path to template * @@ -64,10 +79,31 @@ public function getDisplayImage() */ public function getTemplate() { + $designVersion = (string)$this->_scopeConfig->getValue( + 'mfblog/design/version', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); + $templateName = (string)$this->_scopeConfig->getValue( 'mfblog/sidebar/'.$this->_widgetKey.'/template', \Magento\Store\Model\ScopeInterface::SCOPE_STORE ); + + if ($designVersion == '2025-04') { + $template = $this->_scopeConfig->getValue( + 'mfblog/sidebar/'.$this->_widgetKey.'/template_new', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); + if (strpos((string) parent::getTemplate(), 'article.phtml') !== false) { + return parent::getTemplate(); + } + if ($template == 'default') { + $templateName = 'modern'; + } else { + return 'Magefan_BlogExtra::sidebar/recent_2025_04.phtml'; + } + } + if ($template = $this->templatePool->getTemplate('blog_post_sidebar_posts', $templateName)) { $this->_template = $template; } diff --git a/Block/Widget/Featured.php b/Block/Widget/Featured.php index b6fd5cf8..a56335ef 100644 --- a/Block/Widget/Featured.php +++ b/Block/Widget/Featured.php @@ -23,7 +23,7 @@ class Featured extends \Magefan\Blog\Block\Sidebar\Featured implements \Magento\ public function _toHtml() { $this->setTemplate( - $this->getData('custom_template') ?: 'Magefan_Blog::widget/recent.phtml' + $this->getCustomTemplate() ); return \Magento\Framework\View\Element\Template::_toHtml(); @@ -72,4 +72,34 @@ public function getTemplate() { return \Magefan\Blog\Block\Post\PostList\AbstractList::getTemplate(); } + + /** + * @return mixed + */ + public function getElementClass(){ + return 'featured'; + } + + /** + * @return string + */ + public function getCustomTemplate() { + $designVersion = $this->_scopeConfig->getValue('mfblog/design/version', \Magento\Store\Model\ScopeInterface::SCOPE_STORE); + if ($designVersion === '2025-04' && $this->getTemplate() && strpos($this->getTemplate(), 'article.phtml') !== false) { + return $this->getTemplate(); + } + if ($this->getData('mf_template')) { + if ($designVersion == '2025-04') { + $this->setNewDesignType($this->getData('mf_template')); + return 'Magefan_BlogExtra::widget/blog-widget-2025-04.phtml'; + } + + if ($template = $this->templatePool->getTemplate('blog_post_list', $this->getData('mf_template'))) { + return $template; + } + } elseif ($this->getData('custom_template')) { + return $this->getData('custom_template'); + } + return 'Magefan_Blog::widget/recent.phtml'; + } } diff --git a/Block/Widget/Recent.php b/Block/Widget/Recent.php index 270e4556..1d21db48 100755 --- a/Block/Widget/Recent.php +++ b/Block/Widget/Recent.php @@ -32,6 +32,9 @@ class Recent extends AbstractList implements \Magento\Widget\Block\BlockInterfac */ protected $_category; + + protected $mfTemplate = null; + /** * Construct * @@ -64,7 +67,7 @@ public function __construct( public function _toHtml() { $this->setTemplate( - $this->getData('custom_template') ?: 'Magefan_Blog::widget/recent.phtml' + $this->getCustomTemplate() ); foreach ($this->getPostCollection() as $item) { @@ -207,4 +210,36 @@ public function getCollectionOrderDirection() return parent::getCollectionOrderDirection(); } + + /** + * @return mixed + */ + public function getElementClass(){ + return 'recent'; + } + + /** + * @return string + */ + public function getCustomTemplate() { + $designVersion = $this->_scopeConfig->getValue('mfblog/design/version', \Magento\Store\Model\ScopeInterface::SCOPE_STORE); + if ($designVersion === '2025-04' && $this->getTemplate() + && strpos($this->getTemplate(), 'article.phtml') !== false + ) { + return $this->getTemplate(); + } + if ($this->getData('mf_template')) { + if ($designVersion === '2025-04') { + $this->setNewDesignType($this->getData('mf_template')); + return 'Magefan_BlogExtra::widget/blog-widget-2025-04.phtml'; + } + + if ($template = $this->templatePool->getTemplate('blog_post_list', $this->getData('mf_template'))) { + return $template; + } + } elseif ($this->getData('custom_template')) { + return $this->getData('custom_template'); + } + return 'Magefan_Blog::widget/recent.phtml'; + } } diff --git a/Model/Config/Source/Template.php b/Model/Config/Source/Template.php index e19080f0..16ab371e 100644 --- a/Model/Config/Source/Template.php +++ b/Model/Config/Source/Template.php @@ -55,8 +55,8 @@ public function toOptionArray():array $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $config = $objectManager->get(\Magefan\Blog\Model\Config::class); - if ($this->templateType == 'blog_post_list' && ($config->getConfig('mfblog/developer/version') == '2025-04')) { - $this->templateType = 'blog_post_list_new'; + if ($this->templateType == 'blog_post_list' && ($config->getConfig('mfblog/design/version') == '2025-04')) { + $this->templateType = 'blog_post_list_2025_04'; } if (!isset($this->options[$this->templateType])) { diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 806867a6..0452e9cb 100755 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -38,6 +38,11 @@ + + + Magefan\Blog\Model\Config\Source\DesignVersion + Magefan\Blog\Model\Config\Source\PageLayout @@ -98,14 +103,14 @@ Magefan\Blog\Model\Config\Source\PostListTemplate - 2024-12 + 2024-12 Magefan\Blog\Model\Config\Source\PostListTemplateNew - 2025-04 + 2025-04 @@ -134,6 +139,9 @@ + + 2024-12 + Magefan\Blog\Model\Config\Source\PostViewTemplate @@ -151,6 +159,15 @@ Magefan\Blog\Model\Config\Source\LatestFromCategoryTemplate 1 + 2024-12 + + + + + Magefan\Blog\Model\Config\Source\LatestFromCategoryTemplateNew + + 1 + 2025-04 @@ -172,6 +189,15 @@ Magefan\Blog\Model\Config\Source\RelatedPostTemplate 1 + 2024-12 + + + + + Magefan\Blog\Model\Config\Source\RelatedPostTemplateNew + + 1 + 2025-04 @@ -381,6 +407,7 @@ Magefan\Blog\Model\Config\Source\NextPrevPostTemplate 1 + 2024-12 @@ -444,14 +471,14 @@ Magefan\Blog\Model\Config\Source\PostListTemplate - 2024-12 + 2024-12 Magefan\Blog\Model\Config\Source\PostListTemplateNew - 2025-04 + 2025-04 @@ -501,7 +528,7 @@ Magefan\Blog\Model\Config\Source\PostListTemplate 1 - 2024-12 + 2024-12 @@ -509,7 +536,7 @@ Magefan\Blog\Model\Config\Source\PostListTemplateNew 1 - 2025-04 + 2025-04 @@ -609,14 +636,14 @@ Magefan\Blog\Model\Config\Source\PostListTemplate - 2024-12 + 2024-12 Magefan\Blog\Model\Config\Source\PostListTemplateNew - 2025-04 + 2025-04 @@ -675,10 +702,23 @@ Magefan\Blog\Model\Config\Source\SidebarPostsTemplate + + 2024-12 + + + + + Magefan\Blog\Model\Config\Source\SidebarPostsTemplateNew + + 2025-04 + Magento\Config\Model\Config\Source\Yesno + + 2024-12 + @@ -696,6 +736,16 @@ Magefan\Blog\Model\Config\Source\SidebarPostsTemplate + + 2024-12 + + + + + Magefan\Blog\Model\Config\Source\SidebarPostsTemplateNew + + 2025-04 + @@ -721,6 +771,16 @@ Magefan\Blog\Model\Config\Source\SidebarPostsTemplate + + 2024-12 + + + + + Magefan\Blog\Model\Config\Source\SidebarPostsTemplateNew + + 2025-04 + @@ -858,6 +918,15 @@ Magefan\Blog\Model\Config\Source\RelatedPostTemplate 1 + 2024-12 + + + + + Magefan\Blog\Model\Config\Source\RelatedPostTemplateNew + + 1 + 2025-04 @@ -963,7 +1032,7 @@ - Magefan\Blog\Model\Config\Source\PermalinkType + Magefan\Blog\Model\Config\Source\PermalinkType @@ -1204,11 +1273,6 @@ Magento\Config\Model\Config\Source\Yesno - - - Magefan\Blog\Model\Config\Source\DesignVersion - diff --git a/etc/config.xml b/etc/config.xml index 9a075cb9..a71129a7 100755 --- a/etc/config.xml +++ b/etc/config.xml @@ -24,6 +24,7 @@ 0 + 2024-12 F d, Y 1 diff --git a/etc/di.xml b/etc/di.xml index e23ef0fe..da98ff04 100755 --- a/etc/di.xml +++ b/etc/di.xml @@ -140,7 +140,7 @@ - blog_post_list_new + blog_post_list_2025_04 @@ -163,6 +163,16 @@ blog_post_sidebar_posts + + + blog_post_view_related_post_2025_04 + + + + + blog_post_sidebar_posts_2025_04 + + @@ -205,5 +215,10 @@ blog_post_view_latest_from_category + + + blog_post_view_latest_from_category_2025_04 + + diff --git a/etc/widget.xml b/etc/widget.xml index 6ebb402f..efceebf0 100755 --- a/etc/widget.xml +++ b/etc/widget.xml @@ -47,7 +47,25 @@ Leave blank or use date format YYYY-MM-DD. - + + + Choose the template type to use. + + + + + + + + + + + + Magefan_Blog::widget/recent.phtml.
@@ -78,6 +96,9 @@ Magefan_BlogExtra::post/list/block-5-3.phtml
                 ]]>
+                
+                    
+                
             
         
     
@@ -99,7 +120,25 @@
                     
                 
             
-            
+            
+                
+                Choose the template type to use.
+                
+                    
+                    
+                
+            
+            
+                
+                
+                    
+                
+            
+            
                 
                 Magefan_Blog::widget/recent.phtml.
@@ -130,6 +169,9 @@ Magefan_BlogExtra::post/list/block-5-3.phtml
                 ]]>
+                
+                    
+                
             
         
     
diff --git a/view/frontend/templates/post/view/comments/magefan.phtml b/view/frontend/templates/post/view/comments/magefan.phtml
index 4d59c1fc..af53576f 100644
--- a/view/frontend/templates/post/view/comments/magefan.phtml
+++ b/view/frontend/templates/post/view/comments/magefan.phtml
@@ -38,13 +38,8 @@
                   data-mage-init='{"validation":{}}'>
                 getBlockHtml('formkey') ?>
                 
-                
-                
- getCustomerGroupId()) { ?> + getCustomerGroupId()) { ?>
- + + + +
displayPrivacyPolicyCheckbox()) { ?> getChildBlock('display_privacy_policy_checkbox')->setCommentType('post')->toHtml(); ?> @@ -76,15 +77,17 @@
getChildHtml('blog.post.comments.magefan.additional'); ?>
- - - - - - +
+ + + + + +
+
diff --git a/view/frontend/web/css/blog-m.css b/view/frontend/web/css/blog-m.css index 6c5dc53c..e863a325 100644 --- a/view/frontend/web/css/blog-m.css +++ b/view/frontend/web/css/blog-m.css @@ -66,6 +66,7 @@ .post-list .hidden {display:none;} .post-view .post-bottom {margin-top:30px;} +/* Next Prev */ .post-view .post-nextprev-hld {margin-bottom: 30px;} .post-view .post-nextprev-hld .nextprev-link {font-weight: 700;} .post-view .post-nextprev-hld .prev-link {float:left} diff --git a/view/frontend/web/css/blog-new.css b/view/frontend/web/css/blog-new.css index cbb7eb48..de8439ce 100755 --- a/view/frontend/web/css/blog-new.css +++ b/view/frontend/web/css/blog-new.css @@ -111,10 +111,11 @@ body.blog-page { /* Page Title */ /*.blog-post-view .page-title-wrapper .page-title {font-size: 35px;line-height: 1.2;margin-bottom: 20px;}*/ /* Category */ +.blog-post-view .post-category {margin-bottom: 20px;} .blog-post-view .post-category a {display: inline-block;margin: 0 5px 0 0;padding: 5px 10px;background: #000;color: #fff;font-size: 11px;line-height: 12px;font-weight: 500;text-decoration: none;text-transform: uppercase;} /* Post Data */ -.blog-post-view .post-data-wrap {font-size: 13px;font-family: sans-serif;margin-bottom: 30px;} +.blog-post-view .post-data-wrap {font-size: 13px;font-family: sans-serif;margin-bottom: 20px;} .blog-post-view .post-data-wrap a {font-weight: 600;} .blog-post-view .post-data {color: #bbbbbb;} /* Post View */ @@ -158,10 +159,37 @@ body.blog-page { .blog-post-view .post-gallery .gallery-image-hld img {} /* Post Navigation */ -.blog-post-view .post-nextprev {display: flex;padding: 20px 0;margin-bottom: 30px;border-top: 1px solid var(--border-color);border-bottom: 1px solid var(--border-color);} -.blog-post-view .post-nextprev .nextprev-link {display: block;font-size: 20px;/*color: #222222;*/font-weight: 600;text-align: right;opacity: 0.7;} +.blog-post-view .post-nextprev {display: flex;flex-wrap: wrap;padding: 20px 0;margin-bottom: 30px;border-top: 1px solid var(--border-color);border-bottom: 1px solid var(--border-color);} +.blog-post-view .post-nextprev > div {flex: 0 0 50%;max-width: 50%;} +.blog-post-view .post-nextprev .nextprev-link {display: block;font-size: 20px;/*color: #222222;*/font-weight: 600;opacity: 0.7;} .blog-post-view .post-nextprev .nextprev-link:hover {text-decoration: none;} .blog-post-view .post-nextprev .nextprev-link span {display: block;color: #bbbbbb;font-size: 14px;font-weight: normal;} +.blog-post-view .post-nextprev .post-next .nextprev-link {text-align: right;} + +/* Post Author */ +.blog-page .block-author {display: flex;flex-direction: column;gap: 16px;margin-bottom: 30px;} +.blog-page .block-author .author {display: flex;flex-direction: column;min-width: 300px;flex: 1 1;padding: 20px;border: 1px solid #d5d6da;margin-bottom: 0;} +.blog-page .block-author .author .block-info {display: flex;} +.blog-page .block-author .author .block-info .block-img {width: 10%;flex: 0 0 100px;margin-right: 20px;} +.blog-page .block-author .author .block-info .block-img img {width: 100px;height: auto;} +.blog-page .block-author .author .block-info .block-data {flex: 1 1;} +.blog-page .block-author .author .block-info .block-data .author-name {margin: 7px 0;font-size: 17px;line-height: 21px;font-weight: 700;} +.blog-page .block-author .author .block-info .block-data .author-position {opacity: 0.7;margin: 5px 0;font-weight: 600;} +.blog-page .block-author .author .block-info .block-data .social-icons {display: flex;} +.blog-page .block-author .author .block-info .block-data .social-icons .icon {padding: 5px;} +.blog-page .block-author .author .block-info .block-data .social-icons .icon:nth-child(1) {padding-left: 0;} +.blog-page .block-author .author .block-info .block-data .social-icons .icon img {width: 18px;height: 18px;} +.blog-page .block-author .author .block-info .block-data .social-icons .icon img:hover {opacity: .7;} +.blog-page .block-author .author .block-description {display: flex;flex-direction: column;flex-grow: 1;width: 100%;} +.blog-page .block-author .author .block-description .block-content {margin-top: 10px;} +.blog-page .block-author .author .block-description .action {margin-top: auto;} +.blog-page .block-author .author .block-description .action a {color: #fff;} +.blog-page .block-author .author .block-description .action a:hover, +.blog-page .block-author .author .block-description .action a:visited {color: #fff;} +.blog-page .block-author .author .block-description .a-right {text-align: right;} +@media only screen and (max-width: 768px) { + .blog-page .column.main .block-author {flex-direction: column;} +} /* Block Related */ .blog-post-view .post-bottom .block.related {margin-bottom: 0;} diff --git a/view/frontend/web/css/comments.css b/view/frontend/web/css/comments.css index c626454b..a08b616f 100644 --- a/view/frontend/web/css/comments.css +++ b/view/frontend/web/css/comments.css @@ -8,7 +8,7 @@ #post-comments * {box-sizing: border-box;font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;} /* Styles For All Blocks*/ -.c-count {margin-bottom: 15px;font-weight: 700;padding-bottom: 10px;font-size: 16px;border-bottom: 1px solid #bbbbbb;color: #222;} +.c-count {margin-bottom: 15px;font-weight: 700;padding-bottom: 10px;font-size: 16px;color: #0B0B0B;} .c-img {width: 48px;position: absolute; left: 0;top: 0;z-index: 5;} .c-img img {width: 100%;} .c-reply, .c-comment {position: relative;margin-bottom: 18px;} @@ -19,11 +19,13 @@ /* Reply Form */ .c-replyform textarea, -.c-replyform input {color: #222;background: #fff !important;display: block;} -.c-replyform textarea {padding: 8px;height: 70px;border: 1px solid #bbbbbb;} +.c-replyform input {color: #222;background: #fff !important;display: block;border-radius: 8px;padding: 12px 14px;border: 1px solid #bbbbbb;} +.c-replyform textarea {height: 132px;} +.c-replyform input {height: 52px;} .c-replyform.no-active textarea {border-bottom: 1px solid #bbbbbb;height: 60px;} .c-replyform textarea:focus, .c-replyform input:focus {box-shadow:none;} +.c-replyform .actions {display: flex;align-items: center;justify-content: flex-end;margin-top: 24px;} .c-replyform button {-webkit-transition: all 0.2s;-ms-transition: all 0.2s;transition: all 0.2s;} .c-replyform button:hover {-webkit-transition: all 0.2s;-ms-transition: all 0.2s;transition: all 0.2s;} @@ -34,9 +36,10 @@ /* Form */ .c-replyform .c-btn-hld {margin-top: 20px;} .c-replyform.no-active .c-btn-hld {display: none;} -.c-replyform .c-btn-hld .lr-hld { +.c-replyform .lr-hld { display: -webkit-flex;display: -ms-flexbox;display: flex; -webkit-justify-content: center;-ms-flex-pack: justify;justify-content: space-between; + margin-bottom: 24px; } .c-replyform .left-hld, .c-replyform .right-hld { @@ -65,7 +68,7 @@ /* Button */ -.c-replyform button {display: inline-block;color: #fff;background-color: #4db2ec;border: none;border-radius: 0;font-size: 13px;font-weight: 500;line-height: 1;padding: 10px 15px;margin-top: 20px;} +.c-replyform button {display: inline-block;color: #fff;background-color: #4db2ec;border: none;border-radius: 0;font-size: 13px;font-weight: 500;line-height: 1;padding: 10px 15px;} .c-replyform button:hover {color: #ffffff;background-color: #222222;} .c-replyform button.cancel {background-color: #f6f7f9;border-color: #ced0d4;color: #4b4f56;} .c-replyform button.cancel:hover {background-color: #e9ebee;} @@ -81,8 +84,8 @@ /* Comment */ .c-comments {margin-top: 20px;border-top: 1px solid #ddd;padding-top: 30px;padding-left: 25px;} -.c-comments .c-comment {border-bottom: 1px dashed #eee;} -.c-comments .c-comment:last-child{border-bottom: none} +/*.c-comments .c-comment {border-bottom: 1px dashed #eee;}*/ +.c-comments .c-comment:last-child {border-bottom: none} .c-post .p-info {margin-bottom: 10px;} .c-post .p-name {font-weight: 700;/*color: #222222;*/display: inline-block;margin-right: 10px;font-size: 14px;line-height: 20px;} .c-post .publish-date {font-size: 11px;color: #bbbbbb;display: inline-block;line-height: 20px;} From bdb05526ffa9e90ddf3cf81db37670355f1b37bf Mon Sep 17 00:00:00 2001 From: Bogdan Kitura Date: Mon, 12 May 2025 16:53:04 +0200 Subject: [PATCH 3/8] 13277-new-design-magefan-blog [in progress] --- Block/Sidebar/Featured.php | 5 +++++ Block/Widget/Featured.php | 14 +++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Block/Sidebar/Featured.php b/Block/Sidebar/Featured.php index d601d10d..00641f05 100644 --- a/Block/Sidebar/Featured.php +++ b/Block/Sidebar/Featured.php @@ -61,9 +61,14 @@ protected function getPostIdsConfigValue() \Magento\Store\Model\ScopeInterface::SCOPE_STORE ); } + + /** + * @return string + */ public function getWidgetKey() { return (string)$this->_widgetKey; } + /** * Retrieve true if display the post image is enabled in the config * @return bool diff --git a/Block/Widget/Featured.php b/Block/Widget/Featured.php index a56335ef..1c4d2ab9 100644 --- a/Block/Widget/Featured.php +++ b/Block/Widget/Featured.php @@ -46,9 +46,21 @@ public function getTitle() */ protected function getPostIdsConfigValue() { - return (string)$this->getData('posts_ids'); + $postsIds = (string) $this->getData('posts_ids'); + $registeredPostsIds = $this->_coreRegistry->registry('posts_ids'); + + if ($postsIds !== '' && $postsIds !== $registeredPostsIds) { + if ($registeredPostsIds !== null) { + $this->_coreRegistry->unregister('posts_ids'); + } + $this->_coreRegistry->register('posts_ids', $postsIds); + } + + return $this->_coreRegistry->registry('posts_ids'); } + + /** * Retrieve post short content * From 9942970d9baac96bce5dcea0a06b8f6f0c125328 Mon Sep 17 00:00:00 2001 From: Bogdan Kitura Date: Wed, 14 May 2025 08:13:56 +0200 Subject: [PATCH 4/8] 13277-new-design-magefan-blog [implemented] --- Block/Post/PostList/AbstractList.php | 11 +++++------ etc/config.xml | 7 +++++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Block/Post/PostList/AbstractList.php b/Block/Post/PostList/AbstractList.php index 01b9c0b2..65c3431d 100755 --- a/Block/Post/PostList/AbstractList.php +++ b/Block/Post/PostList/AbstractList.php @@ -292,20 +292,19 @@ public function getNewDesignType() { if (!$this->templateType) { if (!empty($this->templatePool->getAll('blog_post_list_2025_04')[$this->getPostTemplateType()])) { $this->setNewDesignType($this->getPostTemplateType()); - } else if ($this->getRequest()->getFullActionName() == 'blog_index_index') { + } else { $this->setNewDesignType( - $this->_scopeConfig->getValue('mfblog/index_page/templates_new', + $this->_scopeConfig->getValue('mfblog/post_list/templates_new', \Magento\Store\Model\ScopeInterface::SCOPE_STORE) ); - return $this->templateType; - } else { + } + if ($this->getRequest()->getFullActionName() == 'blog_index_index') { $this->setNewDesignType( - $this->_scopeConfig->getValue('mfblog/post_list/templates_new', + $this->_scopeConfig->getValue('mfblog/index_page/templates_new', \Magento\Store\Model\ScopeInterface::SCOPE_STORE) ); } } - return $this->templateType; } diff --git a/etc/config.xml b/etc/config.xml index a71129a7..9c70486f 100755 --- a/etc/config.xml +++ b/etc/config.xml @@ -40,6 +40,7 @@ 0> 0