本文整理匯總了PHP中Self::setMenu方法的典型用法代碼示例。如果您正苦於以下問題:PHP Self::setMenu方法的具體用法?PHP Self::setMenu怎麽用?PHP Self::setMenu使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Self
的用法示例。
在下文中一共展示了Self::setMenu方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: genMainMenu
public static function genMainMenu()
{
Self::setMenu();
$aryMenu = Static::$arrMainMenu;
$menu = Menu::handler('mainmenu');
foreach ($aryMenu as $lv1) {
if (isset($lv1['childrens']) && !empty($lv1['childrens']) && is_array($lv1['childrens'])) {
// With level 2
$menuItems = Menu::items();
foreach ($lv1['childrens'] as $lv2) {
$menuItems->add($lv2['url'], $lv2['rawContent']);
}
$menu->add($lv1['url'], $lv1['rawContent'], $menuItems, null, ['class' => 'treeview']);
} else {
$menu->add($lv1['url'], $lv1['rawContent']);
}
}
/*$menu->add('dashboard', '<i class="fa fa-dashboard"></i> <span>Dashboard</span>')
->add('contacts', '<i class="fa fa-dashboard"></i> <span>Contact</span> <small class="badge pull-right bg-yellow">12</small>')
->add('#', '<i class="fa fa-calendar"></i> <span>Parent</span> <i class="fa fa-angle-left pull-right"></i>', Menu::items()
// ->prefixParents()
->add('#', '<i class="fa fa-angle-double-right"></i>Menu 1')
->add('#', '<i class="fa fa-angle-double-right"></i>Menu 2')
->add('#', '<i class="fa fa-angle-double-right"></i>Menu 3')
, null, [ 'class' => "treeview" ]
)
// ->raw(null, null, ['class' => 'divider'])
->add('inbox', '<i class="fa fa-envelope"></i> <span>Inbox</span>');*/
//styling
$menu->addClass('sidebar-menu')->getAllItemLists()->map(function ($item) {
if ($item->isActive()) {
$item->addClass('active');
}
if ($item->hasChildren()) {
$item->addClass('treeview-menu');
}
});
return $menu;
}