forked from bruno-barros/w.eloquent
-
Notifications
You must be signed in to change notification settings - Fork 0
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
.
Menu::add(string $name, string $description, array $arguments)->after(string $str)->before(string $str);
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') }}
The arguments theme_location
and menu
will be set to the name of the menu ($name
).