Magento Forum

   
when is a category considered as active in the top menu ? 
 
Capitaine Commerce
Member
 
Avatar
Total Posts:  68
Joined:  2007-09-01
Lille, France
 

Hi folks !

I want to customize the top menu in a template i am currently creating.

The top menu in my template is located in :
/app/design/frontend/default/my_template/catalog/navigation/top.phtml

<ul id="mainNav">
    
<?foreach ($this->getStoreCategories(10) as $_category):?>
        <?
=$this->drawItem($_category)?>
    <?endforeach?>
 
</ul>
As you can see it, this file calls the drawItem function which is in the /app/code/core/Mage/catalog/block/navigatio.php and here is the function :
public function drawItem($category$level=0$last=false)
    
{
        $html 
'';
        if (!
$category->getIsActive()) {
            
return $html;
        
}

        $children 
$category->getChildren();
        
$hasChildren $children && $children->count();
        
$html.= '<li';
        if (
$hasChildren{
             $html
.= ' onmouseover="toggleMenu(this,1)" onmouseout="toggleMenu(this,0)"';
        
}

        $html
.= ' class="level'.$level;
        if (
$this->isCategoryActive($category)) {
            $html
.= ' active';
        
}
        
if ($last{
            $html 
.= ' last';
        
}
        
if ($hasChildren{
            $cnt 
0;
            foreach (
$children as $child{
                
if ($child->getIsActive()) {
                    $cnt
++;
                
}
            }
            $html 
.= ' parent';
        
}
        $html
.= '">'."\n";
        
$html.= '<a href="'.$this->getCategoryUrl($category).'"><span>'.$category->getName().'</span></a>'."\n";
        
//$html.= '<span>'.$level.'</span>';
        
if ($hasChildren){
            $html
.= '<ul class="level' $level '">'."\n";
            
$j 0;
            foreach (
$children as $child{
                $html
.= $this->drawItem($child$level+1, ++$j >= $cnt);
            
}
            $html
.= '</ul>';
        
}
        $html
.= '</li>'."\n";
        return 
$html;
    
}

Obviously the current category or active category must received an ‘active’ class of style when in use.
Anyway I got a look on the function isCategoryActive() and i saw that it returns always false. Will this function be better implemented in the next version of Magento ?
Is there a way to implement it whitout changing the core code of Magento ?

 
Magento Community Magento Community
Magento Community
Magento Community
 
ad2joe
Member
 
Avatar
Total Posts:  60
Joined:  2007-08-31
 

Hello,

Hate to repeat the same question, but when is the next release scheduled?  smile

Thanks, Joe.

 
Magento Community Magento Community
Magento Community
Magento Community
 
RoyRubin
Magento Team
 
Avatar
Total Posts:  968
Joined:  2007-08-07
Los Angeles, CA
 

We are expecting a release this week smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
ad2joe
Member
 
Avatar
Total Posts:  60
Joined:  2007-08-31
 

Hello,

I still hope to grab the latest release today, before leaving for home smile

Thanks, Joe.

 
Magento Community Magento Community
Magento Community
Magento Community
 
bigtuna
Jr. Member
 
Total Posts:  20
Joined:  2007-11-09
Atlanta, GA USA
 

Hi, I’m wondering is this was fixed and I broke it, or has it not yet been addressed?  In build 6.14, the catagories on the catalog root do not show as ‘active’ when selected or browsing the category. This is something that works fine on the admin side. Any ideas? thanks.

 
Magento Community Magento Community
Magento Community
Magento Community
 
bigtuna
Jr. Member
 
Total Posts:  20
Joined:  2007-11-09
Atlanta, GA USA
 

Hello, this is still not fixed in 7.15480?  Any idea when?

 
Magento Community Magento Community
Magento Community
Magento Community
 
noon
Jr. Member
 
Total Posts:  9
Joined:  2008-01-03
 

Hello, I’d also like to activate the current category.
isCategoryActive() still return false with the Beta 0.8.16100

Is there any replacement hack I could use ?

Here is my web site (wip) : http://www.fitnessproteines.com/ (login: magento pass: magento)
I have only 6 fixed categories. Here is the code of my top.pthml :

<li class="leve0" id="nav-c1"><a href="<?=$this->getUrl('')?>"></a></li>
<
li class="leve0" id="nav-c2"><a href="<?=$this->getUrl('')?>Fitness"></a></li>
<
li class="leve0" id="nav-c3"><a href="<?=$this->getUrl('')?>Musculation"></a></li>
<
li class="leve0" id="nav-c4"><a href="<?=$this->getUrl('')?>Cardio"></a></li>
<
li class="leve0" id="nav-c5"><a href="<?=$this->getUrl('')?>Bien-Etre"></a></li>
<
li class="leve0" id="nav-c6"><a href="<?=$this->getUrl('')?>Regime"></a></li>

I thought I could check the current URL and activate the category that has the same name, but I dont find how to get the current URL.
If you have any idea.

Thanks.

 
Magento Community Magento Community
Magento Community
Magento Community
 
noon
Jr. Member
 
Total Posts:  9
Joined:  2008-01-03
 

I found an ugly hack.
I use the $_SERVER["REQUEST_URI"] value to check if its equal to my category :
Since I have fixed categories, I use this in my top.phtml :

<?if ($_SERVER["REQUEST_URI"== "/index.php/Fitness"):?>
        
<li class="leve0" id="nav-c2-active"><a href="<?=$this->getUrl('')?>Fitness"></a></li>
    
<?else:?>
        
<li class="leve0" id="nav-c2"><a href="<?=$this->getUrl('')?>Fitness"></a></li>
    
<?endif?>
    
    <?if 
($_SERVER["REQUEST_URI"== "/index.php/Musculation"):?>
        
<li class="leve0" id="nav-c3-active"><a href="<?=$this->getUrl('')?>Musculation"></a></li>
    
<?else:?>
        
<li class="leve0" id="nav-c3"><a href="<?=$this->getUrl('')?>Musculation"></a></li>
    
<?endif?>

But maybe the function isCategoryActive could be ALMOST something like :

return ($_SERVER["REQUEST_URI"] == $category->getCategoryUrl())

 
Magento Community Magento Community
Magento Community
Magento Community
 
kirederf
Jr. Member
 
Total Posts:  10
Joined:  2008-01-30
 

Hi,

i was wondering why this is this still not fixed even thought it was announced to be fixed in November...?

Are there any workarounds besides comparing the URI with current category name?

Regards

Fred

 
Magento Community Magento Community
Magento Community
Magento Community
 
YoavKutner
Guru
 
Avatar
Total Posts:  491
Joined:  2007-08-08
 

kirederf - We still have this issue and we are working to resolve it.

Thanks

yoav

 
Magento Community Magento Community
Magento Community
Magento Community
 
kirederf
Jr. Member
 
Total Posts:  10
Joined:  2008-01-30
 

Hi Yoav,

thanks for your reply and good to know that I was not missing the fix smile

Regards

Fred

 
Magento Community Magento Community
Magento Community
Magento Community
 
brianjking
Jr. Member
 
Avatar
Total Posts:  14
Joined:  2008-02-21
Bowling Green, OH
 
YoavKutner - 04 March 2008 04:46 AM

kirederf - We still have this issue and we are working to resolve it.

Thanks

yoav

How does this work currently in version 1.0 or the most recent revision of this? Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
corbykissler
Member
 
Total Posts:  39
Joined:  2008-05-14
 

Seems like it’s still broken . . .

 
Magento Community Magento Community
Magento Community
Magento Community
 
doctorlogos
Sr. Member
 
Avatar
Total Posts:  178
Joined:  2008-05-06
 

I´m still searching a solution for links with class="ACTIVE" downer

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top