Magento Blocks – we have explained the basic block assignment and block postion changing in our last article . we’ll dive deep this time
Magento blocks on particular page-
This is quite interesting and very important for all magento developers, how some of the block calls on some of the pages only like account page or checkout page .
to understand this logic we should have strong understanding of magento routing system , how controllers works and how associated block works based on the urls . Everything in magento is a module , so all the modules have theri controllers which are used for url routing system . lets take an example of url e.g http://example.com/index.php/customer/account/index/
module routes in this way module_controller_action
as you can see here module is customer , controller is accountcontroller and action is indexaction (all magento controller action works in this manner e,g editAction = edit on URL deleteAction = delete). You can verify by visiting this path /app/code/core/Mage/Customer/controllers
also related xml can be found under /app/design/frontend/base/default/layout customer.xml
Magento Reference Block
Now its time to explain reference block as its name suggests reference block is help ful to give a reference to your block . Suppose you want to integrate your block in left postion of the store then you can easily call <reference name=”left”>
<reference name="left"> <block type="core/template" after="-" name="sleek" template ="Sleekaccordian/new.phtml" /></reference>
Reference Action Method
Under reference tag we can call functions as well using action method as per the given example for newsletter.xml
<reference name="customer_account_navigation"> <action method="addLink" translate="label" module="newsletter"> <name>newsletter</name><path>newsletter/manage/</path> <label>Newsletter Subscriptions</label></action> </reference>
this refrence (customer_account_navigation) is defined under customer.xml
<block type="customer/account_navigation" name="customer_account_navigation" before="-" template="customer/account/navigation.phtml"> <action method="addLink" translate="label" module="customer"> <name>account</name><path>customer/account/</path><label>Account Dashboard</label></action> <action method="addLink" translate="label" module="customer"> <name>account_edit</name><path>customer/account/edit/</path> <label>Account Information</label></action> <action method="addLink" translate="label" module="customer"> <name>address_book</name><path>customer/address/</path><label>Address Book</label></action> </block>
now as per the block class if you’ll visit
/app/code/core/Mage/Customer/Block/Account then you’ll find addLink function under Navigation.php
Be the first to comment.