Book Image

Magento 2 Development Cookbook

Book Image

Magento 2 Development Cookbook

Overview of this book

With the challenges of growing an online business, Magento 2 is an open source e-commerce platform with innumerable functionalities that gives you the freedom to make on-the-fly decisions. It allows you to customize multiple levels of security permissions and enhance the look and feel of your website, and thus gives you a personalized experience in promoting your business.
Table of Contents (13 chapters)
12
Index

Creating a widget configuration file


In this recipe, we will extend the features of the Packt_ProductSlider module with a widget configuration file. In this configuration file, we will declare a new widget or frontend app type.

For a new frontend app, we need to configure the following things:

  • Name of the widget (used in the backend)

  • Widget configuration parameters

  • Widget block type

  • Widget templates (the .phtml files)

Getting ready

We will extend the module that we created in the previous recipe with a widget configuration. Ensure that you have the right files installed.

How to do it...

Using the following steps, you can explore the purpose of a widget.xml configuration file:

  1. Create the app/code/Packt/ProductSlider/etc/widget.xml file using the following code:

    <?xml version="1.0" encoding="UTF-8"?>
    <widgets xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Widget:etc/widget.xsd">
      <widget
        id="category_product_slider...