Table of Contents & Menu
Navigation

Customer Header Menu

As of release 1.3.2, the customer header menu is configured using Layout XML.

Compatibility with older versions of Hyvä

Currently, this composable customer header menu is exclusive to Hyvä 1.3 releases.

Releases for Hyvä 1.2 and 1.1 with this new menu structure are planned soon. This will allow extension vendors to customize the customer header menu via Layout XML while maintaining compatibility with older Hyvä versions.

Overview

Each link is a child block of either the header.customer.logged.in.links block or the header.customer.logged.out.links block.

Menu items are displayed based on the visitor's logged-in status and sorted in ascending order (lower `sort_order` values appear first).

There are three types of menu items: Links, Delimiters, and Headings.

The default template Hyva_Theme::sortable-item/link.phtml renders a link. Use the following alternative templates for delimiters and headings:

  • Hyva_Theme::sortable-item/delimiter.phtml
  • Hyva_Theme::sortable-item/heading.phtml

To add a link, create a child block within either header.customer.logged.in.links or header.customer.logged.out.links. Use the Hyva\Theme\Block\SortableItemInterface class. Place this configuration in your theme's default.xml or a module's hyva_default.xml layout file. The default implementation is usually sufficient.

<referenceBlock name="header.customer.logged.in.links">
    <block name="customer.header.orders.link"
           class="Hyva\Theme\Block\SortableItemInterface">
        <arguments>
            <argument name="label" xsi:type="string" translate="true">My Orders</argument>
            <argument name="path" xsi:type="string">sales/order/history</argument>
            <argument name="sort_order" xsi:type="number">30</argument>
        </arguments>
    </block>
</referenceBlock>

Adding Menu Delimiters

Specify a child block with the Hyva_Theme::sortable-item/delimiter.phtml template:

<referenceBlock name="header.customer.logged.in.links">
    <block name="my-custom-delimiter"
           class="Hyva\Theme\Block\SortableItemInterface"
           template="Hyva_Theme::sortable-item/delimiter.phtml"
    >
        <arguments>
            <argument name="sort_order" xsi:type="number">50</argument>
        </arguments>
    </block>
</referenceBlock>

Adding Menu Headings

Specify a child block with the Hyva_Theme::sortable-item/heading.phtml template:

<referenceBlock name="header.customer.logged.in.links">
    <block name="my-custom-header"
           class="Hyva\Theme\Block\SortableItemInterface"
           template="Hyva_Theme::sortable-item/heading.phtml"
    >
        <arguments>
            <argument name="label" xsi:type="string" translate="true">Action Items</argument>
            <argument name="sort_order" xsi:type="number">55</argument>
        </arguments>
    </block>
</referenceBlock>