loic-sharma/menu
最新稳定版本:v1.0.0
Composer 安装命令:
composer require loic-sharma/menu
包简介
An expressive HTML Generator to create menus.
关键字:
README 文档
README
Create an HTML menu easily!
A Few Examples
Creating a New Menu
<?php $factory = new Menu\Factory; $menu = $factory->get('header'); $menu->add('Home', '/'); $menu->add('Blog', '/blog'); $menu->add('Menu', '/menu', function($menu) { $menu->add('Item 1', '/menu/item-1'); $menu->add('Item 2', '/menu/item-2'); }); echo $menu;
Adding Attributes to Menus
<?php $menu->add('First Link', '/', function($item) { $item->link->id = 'a-id'; $item->link->class = 'a-class'; $item->label->id = 'li-id'; $item->label->class = 'li-class'; }); $menu->add('Second Link', function($item) { $item->url = '/uri'; $item->list->id = 'ul-id'; $item->list->class = 'ul-class'; $menu->add('Sub Link', '/sub/link'); });
Filtering Menu Items
Filters can be used to either remove an item from a menu, or to add more attributes to an item.
<?php // Filter all the menus. $factory->addFilter(function($item) { // Remove any items that have the name 'Admin' if($item->name == 'Admin') { $item->remove(); } }); // Filter a specific menu. $menu->addFilter(function($item) { // Modify the li elements. $item->label->class = 'prettify'; });
统计信息
- 总下载量: 355
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2012-12-01