Creating the block and template files
In the previous recipe, you learned how to configure an extra widget type to Magento. Now, it is time to display the widget.
We will extend the widget configuration with the option to select two different templates to render the widget in the frontend.
The second thing that we will do is create a custom Block class where we can write our own specific methods for the widget.
Getting ready
We will work further on the widget module that we created in the previous recipes. Ensure that you have the right code installed.
How to do it...
Using the following steps, you will learn how we can configure a custom Block class with custom templates for a widget instance:
The first thing that we will do is create the
Blockclass for the widget. TheBlockclass will extendMagento\Catalog\Block\Product\List classbecause we need the functionality of that class in our widget type. Create a file calledProductSlider.phpin theapp/code/Packt/ProductSlider/Block/Catalog/Product...