1

When I click on parent category then sub category opens and when I click on subcategory the respective page open but the menu collapse it does not show on which category and sub-category we are. Can anybody solve my issue to show the menu expandable after click on subcategory. This is the code-

<?php $_helper = Mage::helper('catalog/category') ?>
                            <?php $_categories = $_helper->getStoreCategories() ?>
                            <?php $currentCategory = Mage::registry('current_category') ?>

                        <?php if (count($_categories) > 0): ?>
                            <ul>
                                <?php foreach ($_categories as $_category): ?>
                                    <?php if ($currentCategory != NULL) { ?>
                                        <?php if ($currentCategory->getId() == $_category->getId()): ?>
                                            <li class="open">
                                            <?php else: ?>
                                            <li>
                                            <?php endif; ?>
                                            <a href="<?php echo $_helper->getCategoryUrl($_category) ?>">
                                                <?php echo $_category->getName() ?>
                                            </a>
                                            <?php if ($currentCategory->getId() == $_category->getId()){?>
                                                <?php $_category = Mage::getModel('catalog/category')->load($_category->getId()) ?>
                                                <?php $_subcategories = $_category->getChildrenCategories() ?>
                                                <?php if (count($_subcategories) > 0): ?>
                                                    <ul class="subcat heya">

                                                        <?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 } ?>
                                        </li>
                                    <?php }else { ?>
                                        <li>
                                            <a href="<?php echo $_helper->getCategoryUrl($_category) ?>">
                                                <?php echo $_category->getName() ?>
                                            </a> 
                                        </li>
                                    <?php } ?>
                                <?php endforeach; ?>


                            </ul>
                        <?php endif; ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.