Magento Forum

   
Custom child categories
 
cibs
Jr. Member
 
Total Posts:  9
Joined:  2008-09-10
 

Hello,

I am trying to show the child categories on a custom spot on the website. now i got this code so far.. and is is working.
except. when i click on one of the childcategories… the is tries to show the childcategories of the clicked categorie.

so this is my categorie map

cat 1
cat 2
cat 3
cat 3.1
cat 3.2

when i click on cat 3 it is suppos to show cat 3.1 and cat 3.2.... but when i click on cat 3,1 it should stil show 3.1 and 3.2

<?php //if(count($this->getStoreCategories())>1): ?>
    
<ul id="nav">
    
<?php foreach ($this->getStoreCategories() as $_category): ?>
        <?php 
echo $this->drawItem($_category?>
    <?php 
endforeach ?>
    
</ul>
<?php //endif; ?>
<?php //if(count($this->getStoreCategories())>1): ?>
    
<ul id="subnav">
    
<?php foreach ($this->getCurrentChildCategories() as $_childcategory): ?>
        <?php 
echo $this->drawItem($_childcategory,10?>
    <?php 
endforeach ?>
    
</ul>
<?php //endif; ?>

can someone send me in the right direction how to make this happen for version 1.3 +?

 
Magento Community Magento Community
Magento Community
Magento Community
 
clorne
Sr. Member
 
Total Posts:  236
Joined:  2008-01-10
London
 

Without being able to test this code this can only be a suggestion.

Try

<?php //if(count($this->getStoreCategories())>1): ?>
    
<ul id="nav">
    
<?php foreach ($this->getStoreCategories() as $_category): ?>
        <?php 
echo $this->drawItem($_category?>
    <?php 
endforeach ?>
    
</ul>
<?php //endif; ?>
<?php 
      $category 
$this->getCurrentCategory();
      
$id $category->getId();
?>
<?php 
//if(count($this->getStoreCategories())>1): ?>
    
<ul id="subnav">
    
<?php foreach ($this->getCurrentChildCategories() as $_childcategory): ?>
 <?php 
if($_childcategory->getParentId()== $id):?>
        <?php 
echo $this->drawItem($_childcategory,10?>
<?php 
endif; ?>
    <?php 
endforeach ?>
    
</ul>
<?php //endif; ?>

Good luck

 
Magento Community Magento Community
Magento Community
Magento Community
 
cibs
Jr. Member
 
Total Posts:  9
Joined:  2008-09-10
 

Thanx for youre respons.. although this is not exactly what i am looking for.

when i click in categorie 3
i want to show thu subcategories. .. this works until i click on one of the sub categories.
then it wil show de subcategories of categorie 3.1.

so when i click the menuitem for categorie 3 i want to show the links for the subcategories, and want to keep showing it for the time that menu item is “Active”

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