Responsive Nav Menu 2

Daha önceki menüde tüm kategoriler kontrolsüz ve sınırsız sayıda gösteriliyordu. Bu örnekte ise dilediğiniz kategorileri menüde gösterebileceksiniz.

PHP kodları:

$root = wire('pages')->get(1);

function menu_item($template) {
$selector= "template=$template";
$cat = wire('pages')->get($selector);
$active = ( $cat === wire('page') || $cat === wire('page')->rootParent) ? " active" : '';
echo '<li class="dropdown'.$active.'">';
echo '<a class="dropdown-toggle" data-toggle="dropdown" href="'.$cat->url.'">'.$cat->title.'<span class="caret"></span></a>';
echo '<ul class="dropdown-menu">';
foreach ($cat->children as $cat_item) {
$active = ( $cat_item === wire('page') || $cat_item === wire('page')->rootParent) ? 'class="active"' : '';
echo '<li '.$active.'><a href="'.$cat_item->url.'">'.$cat_item->title.'</a></li>';	
}
echo '</ul>';
echo '</li>';
}	

Navigasyon Menu Kodu:

    <nav class="navbar navbar-inverse navbar-fixed-top" >
      <div class="container" >
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> 
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="<?=$root->url?>">cdeniz.com</a>
        </div>
		
        <div id="navbar" class="navbar-collapse collapse">
		    <ul class="nav navbar-nav">
			  <?menu_item(kutuphane)?>
			  <?menu_item(medya)?>
			</ul>
		
        </div><!--/.nav-collapse -->
   </div>
 </nav>	<!-- Fixed navbar ended-->