trendwerk/submenu

Submenu for Timber.

0.1.2 2022-02-01 15:22 UTC

This package is auto-updated.

Last update: 2024-11-29 04:30:38 UTC


README

Submenu for Timber.

Installation

composer require trendwerk/submenu

Usage

  1. Add a new instance of Submenu to Timber's context
  2. Use it like you would use a Timber\MenuItem

Parameters

$submenu = new Submenu($menu);

Example

Add a new instance of Submenu to your context:

use Trendwerk\Submenu\Submenu;
...
$context['submenu'] = new Submenu($menu);

Use submenu as you would use a Timber\MenuItem.

{% if submenu.children %}
  <h3>{{ submenu.title }}</h3>

  <ul>
    {% for item in submenu.children %}
      <li>{{ item.title }}</li>
    {% endfor %}
  </ul>
{% endif %}