adamb/menu-builder
Composer 安装命令:
composer require adamb/menu-builder
包简介
Build a HTML navigation
README 文档
README
Create a HTML menu and breadcrumb menu items from a PHP array
Installation
Installation is available via Composer/Packagist:
composer require adamb/menu-builder
License
This software is distributed under the MIT license. Please read LICENSE for information on the software availability and distribution.
Basic Usage
Add Menu Items
Make a new instance of the Navigation menu builder
<?php $navigation = new Menu\Navigation();
Add some menu items
// Add links individually $navigation->addLink('Home', '/', array('link_order' => -1000)); $navigation->addLink('About Me', '/about-me', array('link_order' => 2)); // Add an array of links $navArray = [ [ 'title' => 'My Link', 'uri' => '/my-link-page', 'link_order' => 3 ], [ 'title' => 'Has Children', 'uri' => '/child/', 'link_order' => 4 'children' => [ [ 'title' => 'Second Child', 'uri' => '/child/second', 'link_order' => 2 ], [ 'title' => 'First Child', 'uri' => '/child/first', 'link_order' => 1 ], [ 'title' => 'Last Child', 'uri' => '/child/last', 'link_order' => 3 ], ] ] ]; $navigation->addLinks($navArray);
The addLink method allows the following:
$navigation->addLink($title, $uri [, $options = []]);
$titleIs a string that should contain the test to display on the link$uriIs a string that should contain the link URI$optionsIs an array that can contain any of the following array elements ['label', 'uri', 'fragment', 'title', 'target', 'rel', 'class', 'id', 'link_order', 'active', 'li_class', 'li_id', 'ul_class', 'ul_id', 'children']
Set Current URI
Set the active link for the menu
$navigation->setCurrentURI('/about-me'); // Makes the about me page the current select item in the menu
Render Menu
Output the menu to the screen
echo($navigation->render());
Render Breadcrumb Menu
Output a breadcrumb menu to the screen
echo($navigation->renderBreadcrumb());
统计信息
- 总下载量: 196
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-03-24