Responsif Nav Menü

Yukarıda sabit  ve mobil telefonlar için kapanan menü şeklinde Bootsrap ve Processwire entegrasyonu

aşağıdaki kodu hemen <body> nin altına ekleyin:

<?php
		$childrenpages="";
		$root = $pages->get(1);
		$rootpage ='<a href="'.$root->url.'">'.$root->title.'</a>';
// **		
		foreach ($root->children as $tree_item) {
		$active = $child === $page ? " active" : '';
		$childrenpages .= '<li'.$active.'><a href="'.$tree_item->url.'">'.$tree_item->title.'</a></li>'; } 
// **
		$savedLanguage = $user->language;

		foreach($languages as $language) {

		  if($language->id == $savedLanguage->id) continue;
		  if(!$page->viewable($language)) continue;
		  $user->language = $language;
		  $language_items.= '<li><a href="'.$page->url.'"> '.$language->title.'  </a></li>';
		}
		$user->language = $savedLanguage; 
		
		if($page->editable()) { $edit='<li><a href="'.$page->editUrl.'"><i class="glyphicon glyphicon-pencil"></i></a></li>';}
// **

		if($user->isLoggedin()) { $login = "<li><a href='{$config->urls->admin}login/logout/'><i class='glyphicon glyphicon-log-out'></i> $user->name</a></li>";} 
		else {$login = "<li><a href='{$config->urls->admin}'><i class='glyphicon glyphicon-log-in'></i></a></li> ";} 
//


?>	
    <!-- Fixed navbar -->
    <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">
		
		<? include('./topnav.inc'); ?>
		
		<ul class="nav navbar-nav">
           	<?=$language_items?>
			<?=$edit?>
			<?=$login?>
		</ul>
		
		 <div class="nav navbar-nav navbar-right">
			<form class="navbar-form" role="search" action="/search/" method="GET" >
				<div class='input-group'>
					<input type="text" class="form-control" name="q" value='<?php echo htmlentities($input->whitelist('q'), ENT_QUOTES, 'UTF-8'); ?>' >
					 <div class="input-group-btn">
						<button class="btn btn-default" type="submit"><i class="glyphicon glyphicon-search"></i></button>
					</div>
				</div>
			</form>
		</div>

    </div><!--/.nav-collapse -->
   </div>
 </nav>	
	<!-- Fixed navbar ended-->

topnav.inc:

<?php namespace ProcessWire;
/*
Navigation for ProcessWire using the Bootstrap 2.2.2 markup
This menu was written by Soma based on work by NetCarver and a bit thrown in by Joss

Navigation Bootstrap 3 update by Damienov, with multi level dropdown support fix
*/


function renderChildrenOf($pa, $output = '', $level = 0)
{
    $output = '';
    $level++;

    foreach ($pa as $child) {
        $atoggle = '';
        $class = '';

        if ($child->numChildren && count($child->parents) == 1) {
            $class .= 'dropdown';
            $atoggle .= ' class="dropdown-toggle" data-toggle="dropdown"';
        } else if ($child->numChildren && count($child->parents) > 1 ) {
            $class .= 'dropdown-submenu';
            $atoggle .= ' class="dropdown-toggle"';
        } else if ($child->numChildren && $child->id != 1) {
            $class .= 'dropdown-menu';
        }

        // Makes the current page and it's top level parent add an active class
        $class .= ($child === wire('page') || $child === wire('page')->rootParent) ? " active" : '';
        $class = strlen($class) ? " class='" . trim($class) . "'" : '';

        if ($child->numChildren && count($child->parents) == 1) {
            // Add Caret if have children
            $output .= "<li$class><a href='$child->url'$atoggle>$child->title <b class='caret'></b></a>";
        } else if ($child->numChildren && count($child->parents) > 1) {
            $output .= "<li$class><a tabindex='-1' href='$child->url'$atoggle>$child->title</a>";
        } else {
            $output .= "<li$class><a href='$child->url'$atoggle>$child->title</a>";
        }

        // If this child is itself a parent and not the root page, then render it's children in their own menu too...
        if ($child->numChildren && $child->id != 1) {
            $output .= renderChildrenOf($child->children, $output, $level);
        }
        $output .= '</li>';
    }
    $outerclass = ($level == 1) ? "nav navbar-nav" : 'dropdown-menu';
    return "<ul class='$outerclass'>$output</ul>";
}

// bundle up the first level pages and prepend the root home page
$homepage = $pages->get(1);
$pa = $homepage->children;
$pa = $pa->prepend($homepage);

// Set the ball rolling...
echo renderChildrenOf($pa);