HI, Now i get all categorys and subcategory. How get only subcategory?
<?php foreach ($this->getStoreCategories() as $_category): ?>
<?php $_menu .= $this->drawItem($_category) ?>
<?php endforeach ?>
HI, Now i get all categorys and subcategory. How get only subcategory?
<?php foreach ($this->getStoreCategories() as $_category): ?>
<?php $_menu .= $this->drawItem($_category) ?>
<?php endforeach ?>
Hi, $this->getStoreCategories() returns a Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection, which has an addPathFilter() method. Look at this method's prototype : it has one argument : $regexp If you know about regular expressions, you can build a regexp which filters your categories by path. Try first to print the categories paths (by doing echo $_category->getPathInStore()), then find a regexp which filters category paths the way you want.
This will give you "mother" categories + 1st level children categories.
<ul>
<?php foreach ($this->getStoreCategories() as $_category): ?>
<li>
<strong><?php echo $_category->getName(); ?></strong>
<?php $_children = $_category->getChildren(); ?>
<?php if($_children->count()) : ?>
<ul>
<?php foreach($_children as $_child) : ?>
<li><?php echo $_child->getName(); ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</li>
<?php endforeach ?>
</ul>
If you only want to display 1st level subcategories just comment/remove the first
<strong><?php echo $_category->getName(); ?></strong>