Skip to content

Instantly share code, notes, and snippets.

@BinaryKitten
Created March 18, 2013 14:43
Show Gist options
  • Save BinaryKitten/5187634 to your computer and use it in GitHub Desktop.
Save BinaryKitten/5187634 to your computer and use it in GitHub Desktop.
Bootstrap Navigation style
<ul class="nav">
<?php foreach ($this->container AS $page) { ?>
<?php
// render li tag and page
$liClass = '';
$liClass .= $page->isActive() ? ' active' : '';
$liClass .= $page->getClass() ? ' ' . $page->getClass() : '';
$linkDropdown = '';
if ($page->hasChildren()) {
$linkDropdown = 'class="dropdown-toggle" data-toggle="dropdown"';
$liClass .= ' dropdown';
}
if (strlen($liClass)) {
$liClass = ' class="' . trim($liClass) . '"';
}
?>
<?php if ($page->isVisible()) { ?>
<li<?=$liClass?>>
<a <?=$linkDropdown; ?> href="<?=$page->getHref();?>"><?php
echo $page->getLabel();
if ($page->hasChildren()) {
?><b class="caret"></b><?php
}
?></a>
<?php if ($page->hasChildren()) {?>
<ul class="dropdown-menu">
<?php
$children = $page->getPages();
foreach ($children AS $child) { ?>
<li>
<?php if ($child->getHref()) { ?><a href="<?=$child->getHref();?>"><?php }?>
<span><?=$child->getLabel();?></span>
<?php if ($child->getHref()) { ?></a><?php }?>
</li>
<?php } ?>
</ul>
<?php } ?>
</li>
<?php } ?>
<?php } ?>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment