Magento – Magento 2 Adding a custom block template to CMS page

blockscustommagento2template

I'm struggling including my custom module/block template into a static CMS page.

Here's my block code:

<block class="Magento\Framework\View\Element\Template" name="custom_slider_block" template="Custom_Slider::slider.phtml" />

How would I implement this in a static CMS page?

Edit:

I've added a block file with the following code:

<?php
 namespace Custom\Slider\Block;

 class Slider extends \Magento\Framework\View\Element\Template
 {
   public function _prepareLayout()
  {
    return parent::_prepareLayout();
   }
 }

and changed my block call to:

{{block class="Custom\Slider\Block\Slider" template="Custom_Slider::slider.phtml"}}

But now I get the error:

Error filtering template: Invalid block type: Custom\Slider\Block\Slider

Edit 2:

Got it working, realised I hadn't included a registration.php file to actually enable the module.

Best Answer

Try the code below

{{block class="Magento\Framework\View\Element\Template" template="Custom_Slider::slider.phtml"}}
Related Topic