Using Magento 1.4.1.1.
After reading a seemingly simple tutorial at http://www.exploremagento.com/magento/override-a-magento-core-block-class.php I ran into some problems. To override the catalog modules breadcrumbs you use the following XML:
<config> <global> <blocks> <catalog> <rewrite> <breadcrumbs>Fido_Catalog_Block_Breadcrumbs</breadcrumbs> </rewrite> </catalog> </blocks> </global> </config>
This is fine for the catalog module, but how do you replace the standard breadcrumbs in 1.4.1.1 which are in core/Mage/Page/Block/Html/Breadcrumbs.php? It took me quite a bit of trial and error, but the key here is the declaration of the block in page.xml:
<block type="page/html_breadcrumbs" name="breadcrumbs" as="breadcrumbs"/>
The type is what indicates how to override. Specifically “page” and “html_breadcrumbs”. To properly override the standard breadcrumbs you would use the following XML:
<config> <global> <blocks> <page> <rewrite> <html_breadcrumbs>AIBooks_Page_Block_Html_Breadcrumbs</html_breadcrumbs> </rewrite> </page> </blocks> </global> </config>
The rest of the article should apply just fine. In my package I mirrored the core code with app/code/local/AIBooks/Page/Block/Html/Breadcrumbs.php with your XML going into app/code/local/AIBooks/Page/etc/config.xml.
Hello,what is the purpose of overriding a block?will it shows additional contents on the screen or we can use the overriden methods of that .php file?
The idea is to replace the default block handling class with one of your own. That way you can control exactly how everything is output. I overrode the default breadcrumb class with my own to make the breadcrumb appear like a ribbon. I added some images and changed the CSS. Basically it gives you complete control over what comes out of that block.
where should i need to specify the first xml file of ur post?
I had been building a package called AIBooks so it goes in: app/code/local/AIBooks/Page/etc/config.xml
The post I linked at the start of the article is a bit more in-depth about how to do the general override part.
I need to know how override admin core block
eg: override the Mage/Adminhtml/Block/Tag/Edit/Accordion.php class
It’s been a long time since I did any Magento so I can’t give that much advice. The basic idea of the post above should work for the admin blocks as well.