I have a left menu which displays on all of my Categroy List and Product Details pages.
I have tweaked it (based on another post in here) so that when a Category is selected the associated sub-categories display also.
What i currently can't get it to do is display the sub-categories when either one of them is selected (it just reverts back to showing the top level categories only) or when a product in one of those sub-categories is being display.
Below is my current code, what tweaks can I make to have the sub-categories main visible for a certain category when the sub-category or product is selected?
<?php $_categories = $this->getStoreCategories(); ?>
<?php $_count = is_array($_categories)?count($_categories):$_categories->count(); ?>
<?php $currentCategory = Mage::registry('current_category') ?>
<?php if($_count): ?>
<div class="block block-layered-nav">
<div class="block-content">
<dl id="narrow-by-list2">
<dd>
<ol>
<?php foreach ($_categories as $_category): ?>
<?php if ($_category->getIsActive()) : ?>
<li class="parent"> <a href="<?php echo $this->getCategoryUrl($_category) ?>"<?php if ($this->isCategoryActive($_category)): ?> class="current"<?php endif; ?>><?php echo $this->htmlEscape($_category->getName()) ?></a> <?php echo $_category->getIncludeInMenu() ?>
<!-- (<?php echo $_category->getProductCount() ?>)-->
<?php if ($currentCategory && $currentCategory->getId() == $_category->getId()): ?>
<?php $_subcategories = $_category->getChildrenCategories() ?>
<?php if (count($_subcategories) > 0): ?>
<ul>
<?php foreach($_subcategories as $_subcategory): ?>
<li class="child"> <a href="<?php echo $this->getCategoryUrl($_subcategory) ?>"<?php if ($this->isCategoryActive($_subcategory)): ?> class="current"<?php endif; ?>><?php echo $this->htmlEscape($_subcategory->getName()) ?></a> </li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<?php endif; ?>
</li>
<?php endif; ?>
<?php endforeach ?>
</ol>
</dd>
</dl>
<script type="text/javascript">decorateDataList('narrow-by-list2')</script>
</div>
</div>
<?php endif; ?>