Skip to content

trendwerk/submenu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Submenu

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);
Parameter Default Required Description
$menu null Yes Menu which should be used, same as TimberMenu

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 %}