Search code examples
magentomagento-1.4magento-1.5

Does not want anchor tag in parent category in left menu in magento?


I am facing one problem; I am having 2 parent category parent1 and parent2 Parent1 contain 4 sub category and parent2 not having any child category.

now what i want is when user click on parent1 then it should not redirect to particular category page but when user click on one of the sub category of parent1 category then it should redirect to particular sub category page but when user click on parent2 (which doesn't contain any child category) then it should redirect to particular parent category page.


Solution

  • You will need to modify the Navigation block.

    Copy code/core/Catalog/Block/Navigation.php

    to

    code/local/Catalog/Block/Navigation.php

    modify this method: _renderCategoryMenuItemHtml() to suite your needs. You will need to check if the category has children and change the HTML markup depending on that.

    This will however, change for both top and left hand navigation. If you want to change just the left hand navigation you can do this:

    a) rename code/local/Catalog/Block/Navigation.php to something else (also change the class name inside the file to Mage_Catalog_Block_Navigationleft), for example

    code/local/Catalog/Block/Navigationleft.php

    b) Change the XML config to use our new block for the left hand nav:

    <reference name="left">
        <block type="catalog/navigationleft" name="catalog.leftnav" after="currency" 
            template="catalog/navigation/left.phtml"/>
    </reference>
    

    Magento will then continue to use the original Navigation block for the top nav :-)