8

How to set a page to display sub-categories and not products?

1 Answer 1

10

To hide products from a category page, set the category's Display Mode to Static block only.

To list all subcategories, include the following bit of code in your catalog/category/view.phtml:

<ul>
<?php foreach ($this->getCurrentCategory()->getChildrenCategories() as $_subcat): ?>
    <li><a href="<?php echo $_subcat->getUrl() ?>"><?php echo Mage::helper('catalog/output')->categoryAttribute($_subcat, $_subcat->getName(), 'name') ?></a></li>
<?php endforeach ?>
</ul>

You may want to add checks for whether the subcategories are active, if there are any at all, and perhaps a flag of some sort to make the whole thing more flexible with a simple Custom Layout Update.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.