Magento 2

I have installed a sample Bannerslider module downloaded from Magestore.

When I call bannerslider.phtml into CMS Home Page, it's showing unreliable error on the home page.

{{block class="Magento\Bannerslider\Block\Slideshow" template="bannerslider.phtml"}}

The error message is We're sorry, an error has occurred while generating this email.

I changed the block class as well, still, it shows the same error. Can you please suggest me a proper way?

If you need furthermore code detail, Please mentioned me in a comment. I am really stuck here.

After uncomment SetEnv MAGE_MODE developer in .htaccess file error message being the change and showing

Error filtering template: Invalid block type: Magento\Bannerslider\Block\Slideshow

By the way, the admin section of this module is working fine.

Block class

namespace Magento\Bannerslider\Block;
use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Element\Template\Context;
use Magento\Framework\Filesystem;
use Magento\Framework\App\Filesystem\DirectoryList;
class Slideshow extends Template
    public function __construct(
        Context $context,
        \Magento\Bannerslider\Model\BannerFactory $bannerFactory,
        \Magento\Framework\Filesystem $fileSystem,
        \Magento\Framework\StoreManagerInterface $storeManager,
        array $data = array()
    ) {
        $this->_fileSystem = $fileSystem;
        $this->_bannerFactory = $bannerFactory;
        $this->_storeManager = $storeManager;
        parent::__construct($context, $data);
    public function _prepareLayout()
        return parent::_prepareLayout();
    public function getBaseJs($fileName){

        return $this->_storeManager->getStore()->getBaseUrl(
    public function getBannerData(){
        $banners = $this->_bannerFactory->create()
        foreach ($banners as $banner){
                $result['banners'][] = $banner->getData();
        return $result;
    public function getBannerImage($imageName) {

        $mediaDirectory = $this->_storeManager->getStore()->getBaseUrl(
        return $mediaDirectory.'bannerslider/images'.$imageName;


<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
    <module name="Magento_Bannerslider" setup_version="1.0.0"/>
  • 3
    you need to uncoment SetEnv MAGE_MODE developer from .htaccess file to eloborate error. Oct 7, 2015 at 10:37
  • Thank you Taral. I have done it. Now error message has been change. I have edited my question now. Oct 7, 2015 at 10:40
  • Please show me your block class and module.xml code.
    – Amit Bera
    Oct 7, 2015 at 12:57
  • I had added block class and module.xml code to post. Oct 7, 2015 at 13:48
  • @TaralPatoliya Thank you for your suggestion... It really helped for me!
    – DRAJI
    Jul 15, 2016 at 5:57

2 Answers 2


Try below code in cms page, If you want to call phtml with in cms page.

{{block class="Magento\Bannerslider\Block\Slideshow" template="Magento_Bannerslider::bannerslider.phtml"}} 

In magento,if you want to add block class in cms page, then you can tre below code

{{block class="Magento\Bannerslider\Block\Slideshow" template="Magento_Bannerslider::bannerslider.phtml"}} 

Formula is :

{{block class="[BlockClassFullName]" template="[VendorName]_[ModuleName]::[YourTemplateFileLocation].phtml"}} 

Default block:

{{block class="Magento\Framework\View\Element\Template" template="[VendorName]_[ModuleName]::[YourTemplateFileLocation].phtml"}} 

This is equal to Magento 1.X version code

{{ block type="core/template" template="YourtemplateFileLocation.phtml"}}
  • hi @Amit, can we use cacheable="false" here? when used in cms Mar 21, 2019 at 13:38
  • Can use but it makes you make non Cacheable
    – Amit Bera
    Mar 21, 2019 at 14:13
  • Yes i need that one, what is the syntax in using cms, i used it but it didn't work Mar 21, 2019 at 14:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.