/ Published in: PHP
Comment
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<ul> <?php $parentCategoryId = 3; foreach (Mage::getModel('catalog/category')->load($parentCategoryId)->getChildrenCategories() as $_category): ?> <li class="<?php echo $_category->getName(); ?>"> <a href="<?php echo $_category->getUrl(); ?>"><?php echo $_category->getName(); ?></a> <?php if ($currentCategory & $currentCategory->getId() == $_category->getId()): ?> <?php $parentCategory = $currentCategory ?> <?php $_category = Mage::getModel('catalog/category')->load($_category->getId()) ?> <?php $_subcategories = $_category->getChildrenCategories() ?> <ul> <?php foreach($_subcategories as $_subcategory): ?> <li> <a href="<?php echo $_helper->getCategoryUrl($_subcategory) ?>"> <?php echo $_subcategory->getName() ?> </a> </li> <?php endforeach; ?> </ul> <?php endif; ?> <?php endif; ?> </li> <?php endforeach