Example #1
0
function bootstrapItems($items)
{
    // Starting from items at root level
    if (!is_array($items)) {
        $items = $items->roots();
    }
    foreach ($items as $item) {
        ?>
		<li<?php 
        if ($item->hasChildren()) {
            ?>
 class="dropdown"<?php 
        }
        ?>
>
		<a href="<?php 
        echo $item->link->get_url();
        ?>
" <?php 
        if ($item->hasChildren()) {
            ?>
 class="dropdown-toggle" data-toggle="dropdown" <?php 
        }
        ?>
>
		 <?php 
        echo $item->link->get_text();
        ?>
 <?php 
        if ($item->hasChildren()) {
            ?>
 <b class="caret"></b> <?php 
        }
        ?>
</a>
		<?php 
        if ($item->hasChildren()) {
            ?>
		<ul class="dropdown-menu">
		<?php 
            bootstrapItems($item->children());
            ?>
		</ul> 
		<?php 
        }
        ?>
		</li>
	<?php 
    }
}
Example #2
0
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="#">Sitepoint</a>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">
        <?php 
echo bootstrapItems($main);
?>
      </ul>
      <form class="navbar-form navbar-left" role="search">
        <div class="form-group">
          <input type="text" class="form-control" placeholder="Search">
        </div>
        <button type="submit" class="btn btn-default">Submit</button>
      </form>
      <ul class="nav navbar-nav navbar-right">
         	<?php 
echo bootstrapItems($user);
?>
      </ul>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>

</body>
</html>