Skip to content

Tutorial: Widget Menu Customisation

Customising Menus for Specific Widget Types

The examples given below apply the changes to all widget types. In cases where the changes should only apply to widgets of a specific type, use the hyva_dashboard_widget_instance_{{WIDGET_TYPE_ID}} handle instead.

Removing Menu Items

  1. Create the hyva_dashboard_widget_instance.xml layout file
  2. Reference the specific menu item block and set the remove attribute to true
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="widget-instance.menu.foo" remove="true"/>
    </body>
</page>

Adding Menu Items

  1. Create the hyva_dashboard_widget_instance.xml layout file
  2. Add a new block to the widget-instance.menu block
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="widget-instance.menu">
            <block name="foo" template="Vendor_Module::path/to/foo.phtml"/>
        </referenceBlock>
    </body>
</page>

Reordering Menu Items

  1. Create the hyva_dashboard_widget_instance.xml layout file
  2. Reference the specific menu item block(s) and use the before and/or after attributes to reposition them
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="widget-instance.menu.foo" before="widget-instance.menu.bar"/>
    </body>
</page>