-
-
Save diogoca/6042991 to your computer and use it in GitHub Desktop.
Twitter Bootstrap Partial View for Zend Navigation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @author Kanstantsin A Kamkou (2ka.by) | |
*/ | |
$html = array('<ul class="nav">'); | |
foreach ($this->container as $page) { | |
// visibility of the page | |
if (!$page->isVisible()) { | |
continue; | |
} | |
// dropdown | |
$dropdown = !empty($page->pages); | |
// header | |
$html[] = '<li' . ($dropdown ? ' class="dropdown"' : '') . '>'; | |
$html[] = '<a href="' . ($dropdown ? '#' : $page->getHref()) . '" ' | |
. 'class="dropdown-toggle" data-toggle="dropdown">'; | |
$html[] = $page->getLabel(); | |
if ($dropdown) { | |
$html[] = '<b class="caret"></b>'; | |
} | |
$html[] = '</a>'; | |
if (!$dropdown) { | |
$html[] = '</li>'; | |
continue; | |
} | |
$html[] = '<ul class="dropdown-menu">'; | |
foreach ($page->pages as $subpage) { | |
// visibility of the sub-page | |
if (!$subpage->isVisible()) { | |
continue; | |
} | |
$html[] = '<li' . ($subpage->isActive() ? ' class="active"' : '') . '>'; | |
$html[] = '<a href="' . $subpage->getHref() . '">'; | |
if ($subpage->get('icon')) { | |
$html[] = '<i class="icon-' . $subpage->get('icon') . '"></i>'; | |
} | |
$html[] = $subpage->getLabel(); | |
$html[] = "</a>"; | |
$html[] = "</li>"; | |
} | |
$html[] = "</ul>"; | |
$html[] = "</li>"; | |
} | |
$html[] = '</ul>'; | |
echo join(PHP_EOL, $html); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @author Kanstantsin A Kamkou (2ka.by) | |
*/ | |
$html = array('<ul class="nav nav-list">'); | |
foreach ($this->container as $page) { | |
// show only the current branch and the visible item | |
if (!$page->isVisible() | |
|| ($this->menu()->getOnlyActiveBranch() && !$page->isActive(true))) { | |
continue; | |
} | |
// header | |
$html[] = '<li class="nav-header">'; | |
$html[] = $page->getLabel(); | |
$html[] = "</li>"; | |
if (!empty($page->pages)) { | |
foreach ($page->pages as $subpage) { | |
// visibility of the sub-page | |
if (!$subpage->isVisible()) { | |
continue; | |
} | |
$html[] = '<li' . ($subpage->isActive() ? ' class="active"' : '') . '>'; | |
$html[] = '<a href="' . $subpage->getHref() . '">'; | |
if ($subpage->get('icon')) { | |
$html[] = '<i class="icon-' . $subpage->get('icon') . '"></i>'; | |
} | |
$html[] = $subpage->getLabel(); | |
$html[] = "</a>"; | |
$html[] = "</li>"; | |
} | |
} | |
} | |
$html[] = '</ul>'; | |
echo join(PHP_EOL, $html); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment