3

I've tried Google - but maybe I just can't word this question correctly to get an answer.

I want my top-level category pages to change the main menu to only show the current category. So, for example, say I have a site selling PC Software and Mac Software. If the user goes to "site.com", then the main menu should have two entries, "PC Software" and "Mac Software", and the subcategories below that.

But if the user is at "site.com/pc", then I want the main menu to show the subcategories of PC Software. So the main menu categories might be "Games", "Utilities", "Productivity", "Graphics", etc. Same thing at "site.com/mac".

Any other pages in the "/pc" section would have that same main menu.

I know I could do this by making them in to separate stores, but there are other reasons I'd prefer not to, if possible. I want it to function as one store, with just the main menu changed.

1 Answer 1

0

You'll most likely need to add some custom code to achieve such. You may also be able to wrap a condition around the display to check for the store id to determine to show such or not.

Something like: if (Mage::app()->getStore()->getStoreId() == 2)

<?php
/*
 * http://fishpig.co.uk - Magento Tutorials
 *
 * Display top level categories and
 * subcategories of the current category
 *
**/
?>
<?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): ?>
            <li>
                <a href="<?php echo $_helper->getCategoryUrl($_category) ?>">
                    <?php echo $_category->getName() ?>
                </a>
                <?php if ($currentCategory &amp;&amp; $currentCategory->getId() == $_category->getId()): ?>
                    <?php $_category = Mage::getModel('catalog/category')->load($_category->getId()) ?>
                    <?php $_subcategories = $_category->getChildrenCategories() ?>
                    <?php if (count($_subcategories) > 0): ?>
                        <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; ?>
    </ul>
<?php endif; ?>

Sauce:

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.