O'Reilly logo

Magento 2 Development Cookbook by Bart Delvaux

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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:

  1. The first thing that we will do is create the Block class ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required