Skip to content
3 changes: 2 additions & 1 deletion Block/Adminhtml/System/Config/Form/InfoBlogExtra.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ protected function getSectionsJson(): string
'mfblog_blog_search',
'mfblog_sidebar_contents',
'mfblog_ai_writer',
'mfblog_draft_autosave'
'mfblog_draft_autosave',
'mfblog_design_version'
]);
return $sections;
}
Expand Down
21 changes: 18 additions & 3 deletions Block/Author/PostList.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
37 changes: 37 additions & 0 deletions Block/Catalog/Product/RelatedPosts.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,50 @@ 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
*
* @return string
*/
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
Expand Down
9 changes: 5 additions & 4 deletions Block/Post/PostList.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,11 @@ 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 */
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;
Expand Down
41 changes: 41 additions & 0 deletions Block/Post/PostList/AbstractList.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -277,4 +282,40 @@ 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 {
$this->setNewDesignType(
$this->_scopeConfig->getValue('mfblog/post_list/templates_new',
\Magento\Store\Model\ScopeInterface::SCOPE_STORE)
);
}
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;
}

/**
* Get template type for new design
*
* @param $templateType
* @return $this
*/
public function setNewDesignType($templateType) {
$this->templateType = $templateType;
return $this;
}
}
2 changes: 1 addition & 1 deletion Block/Post/View/Comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function __construct(
* Block template file
* @var string
*/
protected $_template = 'post/view/comments.phtml';
protected $_template = 'Magefan_Blog::post/view/comments.phtml';

/**
* Retrieve comments type
Expand Down
32 changes: 32 additions & 0 deletions Block/Post/View/RelatedPosts.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,45 @@ 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
*
* @return string
*/
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 = $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
Expand Down
44 changes: 44 additions & 0 deletions Block/Sidebar/Featured.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,32 +62,76 @@ protected function getPostIdsConfigValue()
);
}

/**
* @return string
*/
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
*
* @return string
*/
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();
}
}
36 changes: 35 additions & 1 deletion Block/Sidebar/Popular.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,57 @@ 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
*
* @return string
*/
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;
}
Expand Down
Loading