I need to override the following file function in my custom module
File - Mageplaza\Blog\Block\Post\View Function Name - getBlogTitle()
As I need to remove '- Blog | Ideas & Advice | Carpet Call' from the meta title
- When I override using preference method, I am getting following error
Exception #0 (Magento\Framework\Exception\ValidatorException): Invalid template file: 'post/head.phtml' in module: 'Carpetcall_Blogs'
block's name: 'mpblog.post.head'
Please advice. Following is the new file changes, I made
<?php
namespace Carpetcall\Blogs\Block\Post;
class View extends \Mageplaza\Blog\Block\Post\View
{
public function getBlogTitle($meta = false)
{
$blogTitle = parent::getBlogTitle($meta);
$post = $this->getBlogObject();
if (!$post) {
return $blogTitle;
}
if ($meta) {
if ($post->getMetaTitle()) {
$blogTitle[] = $post->getMetaTitle();
} else {
$blogTitle[] = ucfirst($post->getName());
}
return $blogTitle;
}
return ucfirst($post->getName());
}
}