php - Creating a custom top menu in magento 1.9.2 -


i'm trying crate custom top menu in magento 1.9.2 overriding app/code/core/mage/catalog/block/navigation.php adding custom classes. created a new local extension has following file on it

app/etc/modules/customnav_catalog.xml

<?xml version="1.0"?> <config>   <modules> <customnav_catalog>   <active>true</active>   <codepool>local</codepool>   <version>0.1.0</version> </customnav_catalog>   </modules> </config> 

app/code/local/customnav/catalog/etc/config.xml

<?xml version="1.0"?> <config> <modules>     <customnav_catalog>         <version>0.1.0</version>     </customnav_catalog> </modules> <global>     <helpers>       <customnav_catalog>         <class>customnav_catalog_helper</class>       </customnav_catalog>     </helpers>     <blocks>         <customnav_catalog>             <class>customnav_catalog_block</class>         </customnav_catalog>         <customnav_catalog>             <class>customnav_catalog_block</class>             <rewrite>                 <navigation>customnav_catalog_block_catalog_navigation</navigation>             </rewrite>         </customnav_catalog>     </blocks> </global> </config> 

app/code/local/customnav/catalog/helper/data.php

class customnav_catalog_helper_data extends mage_core_helper_abstract {} 

app/code/local/customnav/catalog/block/navigation.php

inside function _rendercategorymenuitemhtml add line of code add new class doesn't recognize magento

$classes[] = 'nav-item '; 

i add additional bootstrap class navigation.php.

did override navigation.php?

is there other way customize top menu?

no did not. override mage_catalog_block_navigation need place rewrite in specific block-configuration. instead of:

<blocks>     <customnav_catalog>         <class>customnav_catalog_block</class>     </customnav_catalog>     <customnav_catalog>         <class>customnav_catalog_block</class>         <rewrite>             <navigation>customnav_catalog_block_catalog_navigation</navigation>         </rewrite>     </customnav_catalog> </blocks> 

you should write:

<blocks>     <customnav_catalog>         <class>customnav_catalog_block</class>     </customnav_catalog>     <catalog>         <rewrite>             <navigation>customnav_catalog_block_catalog_navigation</navigation>         </rewrite>     </catalog> </blocks> 

the above snippet 'tells' confguration if mage::app()->getlayout()->createblock('catalog/navigation') called (for example) should not return original block, block stated in rewrite-rule (which yours).


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -