Reputation: 2556
I'm using Magento and I am trying to display all sub categories from one category (42) in an unordered list. I'd also only like to show those subcategories that are active.
I've googled lots of 'solutions', but none seem to work for me. I was wondering if anyone has a definitive answer to this?
Thanks, Neil
Upvotes: 0
Views: 638
Reputation: 9233
Use Mage::getModel('catalog/category')->getCategories($parent, $recursionLevel, $sorted)
method, it returns the tree of the subcategories for a particular parent category. $parent in this case is category id, $recursionLevel is a number of levels for selection subcategories, $sorted just indicates whether sort categories or not. Only $parent argument is required for the method calling.
Upvotes: 0
Reputation: 3655
You should use static block. Somwthing like this:
<?php $_categories = $this->getCurrentChildCategories(); ?>
<ul>
<?php foreach ($_categories as $_category): ?>
<?php if($_category->getIsActive()): ?>
<li>
<a href="<?php echo $_category->getURL() ?>" title="<?php echo $this->htmlEscape($_category->getName()) ?>"><?php echo $this->htmlEscape($_category->getName()) ?></a>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
Upvotes: 1