generateNav();
$c = Page::getCurrentPage();
$containsPages = false;
$nh = Loader::helper('navigation');
//this will create an array of parent cIDs
$inspectC=$c;
$selectedPathCIDs=array( $inspectC->getCollectionID() );
$parentCIDnotZero=true;
while($parentCIDnotZero){
$cParentID=$inspectC->cParentID;
if(!intval($cParentID)){
$parentCIDnotZero=false;
}else{
$selectedPathCIDs[]=$cParentID;
$inspectC=Page::getById($cParentID);
}
}
foreach($aBlocks as $ni) {
$_c = $ni->getCollectionObject();
if (!$_c->getCollectionAttributeValue('exclude_globalnav')) {
$target = $ni->getTarget();
if ($target != '') {
$target = 'target="' . $target . '"';
}
if (!$containsPages) {
// this is the first time we've entered the loop so we print out the UL tag
echo("
");
}
$containsPages = true;
$thisLevel = $ni->getLevel();
if ($thisLevel > $lastLevel) {
echo("");
} else if ($thisLevel < $lastLevel) {
for ($j = $thisLevel; $j < $lastLevel; $j++) {
if ($lastLevel - $j > 1) {
echo("
");
} else {
echo("
");
}
}
} else if ($i > 0) {
echo("");
}
$pageLink = false;
if ($_c->getCollectionAttributeValue('replace_link_with_first_in_nav')) {
$subPage = $_c->getFirstChild();
if ($subPage instanceof Page) {
$pageLink = $nh->getLinkToCollection($subPage);
}
}
if (!$pageLink) {
$pageLink = $ni->getURL();
}
if ($c->getCollectionID() == $_c->getCollectionID()) {
echo('' . $ni->getName() . '');
} elseif ( in_array($_c->getCollectionID(),$selectedPathCIDs) && ($_c->getCollectionID() != HOME_CID) ) {
echo('' . $ni->getName() . '');
} else {
echo('' . $ni->getName() . '');
}
$lastLevel = $thisLevel;
$i++;
}
}
$thisLevel = 0;
if ($containsPages) {
for ($i = $thisLevel; $i <= $lastLevel; $i++) {
echo("");
}
}
?>