Skip to content

4.05. Menus

ArachnidsGrip edited this page Apr 15, 2019 · 1 revision

w.eloquent comes with a API to register and show menus.

It's the Menu facade that return a instance of Weloquent\Support\Navigation\Menu.

API

Menu::add(string $name, string $description, array $arguments)->after(string $str)->before(string $str);

Example of use

Create a file your-theme/app/autoload/menus.php. (Now, this file will be required when WordPress starts.)

# menus.php

Menu::add('primary', 'Primary menu',
	array(
		'container'       => 'div',
		'container_class' => 'main-menu',
		'container_id'    => '',
		'menu_class'      => 'nav navbar-nav',
		'menu_id'         => '',
		'fallback_cb'     => 'wp_page_menu',
		'before'          => '',
		'after'           => '',
		'link_before'     => '',
		'link_after'      => '',
		'items_wrap'      => '<ul id="%1$s" class="%2$s">%3$s</ul>',
		'depth'           => 0,
		'walker'          => new \Weloquent\Support\Navigation\BootstrapMenuWalker
	))
	->before('<li><a href="#">Before link</a></li>')
	->after('<li><a href="#">After link</a></li>');

On your template:

{{ Menu::render('primary') }}

Note

The arguments theme_location and menu will be set to the name of the menu ($name).

Clone this wiki locally