witooh / menu-builder
There is no license information available for the latest version (dev-master) of this package.
dev-master
2013-05-08 15:14 UTC
Requires
- php: >=5.3.0
- illuminate/support: 4.0.x
- witooh/tag-builder: dev-master
This package is not auto-updated.
Last update: 2025-01-13 13:13:01 UTC
README
Install
Add this into config/app.php
'providers' => array( ... ... 'Witooh\MenuBuilder\MenuBuilderServiceProvider', ),
and
'aliases' => array( ... ... 'MenuBuilder' => 'Witooh\MenuBuilder\Facades\MenuBuilder', ),
Usage
Implement IMenuBahvior
namespace MyMenu; class MenuBehavior implements IMenuBehavior { public static function makeUL($menuLevel){ return Tag::make('ul'); } public static function makeLI($config, $menuLevel) { if (isset($config['visible']) && $config['visible'] == false) { return false; } $li = Tag::make('li'); $a = Tag::make('a'); if (isset($config['link'])) { $a->attr('href', $config['link']); } else { $a->attr('href', "javascript:;"); } if (isset($config['icon'])) { $icon = Tag::make('i'); $icon->attr('class', $config['icon']); $a->innerHtml($icon); } if (isset($config['title'])) { $title = Tag::make('span'); $title->attr('class', 'title'); $title->innerHtml($config['title']); $a->innerHtml($title); } $li->innerHtml($a); return $li; } }
Set the behavior to MenuBuilder
MenuBuilder::setBehavior('MyMenu\MenuBehavior');
Display the menu in blade
MenuBuilder::make(array( array( 'title'=>'Home 1', 'icon'=>'icon-home', 'menu'=>array( array( 'title'=>'Sub Home 1', 'icon'=>'icon-home', 'link'=>'#', 'menu'=>array( array( 'title'=>'Sub Sub Home 1', 'icon'=>'icon-home', 'link'=>'#', ) ) ) ), ), array( 'title'=>'Home 2', 'icon'=>'icon-home', 'link'=>'#', 'menu'=>array( array( 'title'=>'Sub Home 2', 'icon'=>'icon-home', 'link'=>'#', ) ) ) ));