Submenu for Timber.
composer require trendwerk/submenu
- Add a new instance of Submenu to Timber's context
- Use it like you would use a
Timber\MenuItem
$submenu = new Submenu($menu);
Parameter | Default | Required | Description |
---|---|---|---|
$menu |
null |
Yes | Menu which should be used, same as TimberMenu |
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 %}