Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @ Save this as snippet called "tbNav" :
- <?php
- function displayChildren($page, $current, $startmenu = true, $limits = null) {
- if ($limits != null && array_key_exists($page->slug(), $limits)) {
- $arr = array('order' => 'position ASC, published_on DESC', 'limit' => $limits[$page->slug()]);
- } else
- $arr = array('order' => 'position ASC, published_on DESC');
- if ($page && count($page->children()) > 0) {
- echo ($startmenu) ? '<ul class="dropdown-menu">' : '';
- foreach($page->children($arr) as $menu) :
- if (count($menu->children()) > 0 && $menu->level() > 0) {
- $dropdown = 'dropdown';
- $toggle = 'class="dropdown-toggle" data-toggle="dropdown"';
- } else { $dropdown = ''; $toggle = ''; }
- echo '<li class="'.(in_array($menu->slug(), explode('/', $current->uri())) ? 'active ': null). $dropdown .'">'.$menu->link($menu->title(), $toggle);
- displayChildren($menu, $current, true, $limits);
- echo '</li>';
- endforeach;
- echo ($startmenu) ? '</ul>' : '';
- }
- }
- ?>
- @ Replace current .nav-collapse div with this code :
- <div class="nav-collapse collapse">
- <?php $this->includeSnippet('tbNav'); $page = $this->find('/'); ?>
- <ul class="nav">
- <li<?php echo ($this->level() == 0) ? ' class="active"': null; ?>><?php echo $page->link($page->title); ?></li -->
- <?php displayChildren($page, $this, false); ?>
- </ul>
- </div><!--/.nav-collapse-->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement