$ni->isActive($c) problem

Permalink
Hello everyone,

Im working on a new dropdown menu. If I select the first subpage of a parentpage, $ni->isActive($c) equals 1. If I select the second subpage of a parent $ni->isActive($c) equals null. How come ?. Why won't $ni->isActive($c) equals 1 if I select second or third subpage of a parent. ?

The reason why I need to get this to work is that I need to add a class to the parent ul tag if a subpage of the parent is selected.

Here is my code:
defined('C5_EXECUTE') or die(_("Access Denied."));
   $aBlocks = $controller->generateNav();
   global $c;
   echo '<ul id="nav">';
   $isFirst = true;
      $nh = Loader::helper('navigation');
   foreach($aBlocks as $ni) {
      $_c = $ni->getCollectionObject();
      if (!$_c->getCollectionAttributeValue('exclude_nav')) {
         $thisLevel = $ni->getLevel();
         if ($thisLevel > $lastLevel) {
            echo $ni->isActive($c);
            if ($ni->isActive($c)) { 
            echo("
            <ul class=\"aktiv\">");


Thank you in advance

87up
 
ScottC replied on at Permalink Reply
ScottC
Edit:

looked at the code again, the autonav is a bit "different" in how it returns the value. You'll want to look at the NavigationHelper::getTrailToCollection() and Page::getCurrentPage()->getCollectionID() and then go from there.

I had a project I just did I had to mark the first and last page for each node of the site, this sounds similar to your problem.

-Scott
87up replied on at Permalink Reply 2 Attachments
87up
Hello ScottC

Thank you for your response. :)

What I fail to understand is why $ni->isActive only equals 1 if first subpage is selected.

But if second or third subpage is selected nothing happens.

I have attached to jpg files to illustrate my problem.

As you can see, if I select Underside1 the aktiv class is added to the ul tag. But if I select Underside2 no aktiv class is added to the ul tag. The parent of Underside1 and Underside2 are the same. Is it possible to make $ni->isActive equals 1 if Underside2 is selected aswell ?