Advertisement
lignite0

Menu wielopoziomowe

Nov 19th, 2016
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.95 KB | None | 0 0
  1. <?php
  2.     $menu = [
  3.  
  4.         'Dashboard' => [
  5.             'path' => '/admin',
  6.             'icon' => 'fa fa-dashboard fa-fw',
  7.         ],
  8.  
  9.         'Strony' => [
  10.             'path' => '',
  11.             'icon' => 'fa fa-files-o fa-fw',
  12.             'children' => [
  13.                 'Wyświetl wszystkie strony' => [
  14.                     'path' => '/admin/page/list',
  15.                     'icon' => '',
  16.                 ],
  17.                 'Dodaj nową stronę' => [
  18.                     'path' => '/admin/page/new',
  19.                     'icon' => '',
  20.                 ],
  21.             ],
  22.         ],
  23.  
  24.         'Nawigacja' => [
  25.             'path' => '',
  26.             'icon' => 'fa fa-picture-o',
  27.             'children' => [
  28.                 'Wyświetl wszystkie nawigacje' => [
  29.                     'path' => '/admin/nav/list',
  30.                     'icon' => '',
  31.                 ],
  32.             ],
  33.         ],
  34.  
  35.         'Galerie zdjęć' => [
  36.             'path' => '',
  37.             'icon' => 'fa fa-picture-o',
  38.             'children' => [
  39.                 'Wyświetl wszystkie galerie' => [
  40.                     'path' => '/admin/gallery/list',
  41.                     'icon' => '',
  42.                 ],
  43.                 'Dodaj nową galerie' => [
  44.                     'path' => '/admin/gallery/new',
  45.                     'icon' => '',
  46.                 ],
  47.             ],
  48.         ],
  49.  
  50.     ];
  51. ?>
  52.  
  53.  
  54. <div class="navbar-default sidebar" role="navigation">
  55.     <div class="sidebar-nav navbar-collapse">
  56.         <ul class="nav" id="side-menu">
  57.  
  58.             <!-- <li class="sidebar-search">
  59.                 <div class="input-group custom-search-form">
  60.                     <input type="text" class="form-control" placeholder="Search...">
  61.                         <span class="input-group-btn">
  62.                             <button class="btn btn-primary" type="button">
  63.                                 <i class="fa fa-search"></i>
  64.                             </button>
  65.                         </span>
  66.                 </div>
  67.             </li> -->
  68.  
  69.             <?=view('/admin/parts/sidebar-item.html.php', [
  70.                 'menu' => $menu,
  71.                 'level' => 'nav nav-second-level'
  72.             ])?>
  73.  
  74.         </ul>
  75.     </div>
  76. </div>
  77.  
  78.  
  79. =====================================
  80.  
  81.  
  82. <?php foreach($menu as $name => $node): ?>
  83.     <li>
  84.         <a href="<?=empty($node['path']) ? '#' : url($node['path'])?>">
  85.             <i class="<?=$node['icon']?>"></i>
  86.             <?=trans($name)?>
  87.  
  88.             <?php if (isset($node['children'])): ?>
  89.                 <span class="fa arrow"></span>
  90.             <?php endif ?>
  91.         </a>
  92.  
  93.         <?php if (isset($node['children'])): ?>
  94.             <ul class="<?=$level?>">
  95.                 <?=view('/admin/parts/sidebar-item.html.php', [
  96.                     'menu' => $node['children'],
  97.                     'level' => 'nav nav-third-level'
  98.                 ])?>
  99.             </ul>
  100.         <?php endif ?>
  101.     </li>
  102. <?php endforeach ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement