I have a file left.phtml for a vertical menu. I want to get all subcategories of specific category ID3. I have this code.
<?php if (!Mage::registry('current_category')) return ?>
<?php
$categoryId = 3;
$category = Mage::getModel('catalog/category')->load($categoryId);
$_categories = $category->getChildrenCategories();
?>
<?php $_count = is_array($_categories)?count($_categories):$_categories->count(); ?>
<?php if($_count): ?>
<div class="block block-layered-nav block-layered-nav--no-filters">
<div class="block-content toggle-content open">
<dl id="narrow-by-list2">
<dt><?php echo $this->__('Каталог') ?></dt>
<dd>
<ol>
<?php foreach ($_categories as $_category): ?>
<?php if($_category->getIsActive()): ?>
<li>
<a href="<?php echo $this->getCategoryUrl($_category) ?>"<?php if ($this->isCategoryActive($_category)): ?> class="current"<?php endif; ?>>
<?php echo $this->escapeHtml($_category->getName()) ?>
</a>
</li>
<?php endif; ?>
<?php endforeach ?>
</ol>
</dd>
</dl>
<script type="text/javascript">decorateDataList('narrow-by-list2')</script>
</div>
</div>
<?php endif; ?>
Example:
Category ID 3 (level 0)
Category (level 1)
Subcategory (level 2)
Subcategory (level 3)
Subcategory
Subcategory (level 3)
Subcategory
Subcategory (level 3)
Category (level 1)
Subcategory
Subcategory
Subcategory
Category (level 1)
Subcategory
Subcategory
Subcategory