We have completed a series of articles about Blocks in Magento in the easiest way to understand. Now let’s start the new tutorial topic of Layout for these next articles. Layout is the part of template system in Magento written by XML language. The layout XML files are used to define displayed structure in Magento sites. Read now!
Describe elements of layout XML schema:
The layout XML file of Magento includes:
1. Layout handles:
– Each of layout handles is proportionate to one page’s layout.
– A layout XML file contains many layout handles
– The Layout handle <default> is always called on any pages
– Based on a Controller action and has the form of module_controller_action
For example: category_catagory_default
2. Components of layout handles:
– Label: the label of handles
– Reference: a link to an available block. It is used to add a children block or update a block, having feature name to put pointer to an existing block.
- Block: define a new block. A block consists of:
- name : to show the name of block (unique in a rendered page)
- as: the block’s name, is used to call a block in phtml file (unique in a parent block)
- Type: to show the name of class (core/template). In case it is a type or subtype of core/tempalte, the template feature is added to set the template.
- template: link of phtml file
- Remove: to delete an available block
- Action: to call a function of instance in reference or block
- Ifconfig
<action method="addLink" translate="label title" module="contacts" ifconfig="contacts/contacts/enabled"><label>Contact Us</label><url>contacts</url><title>Contact Us</title><prepare>true</prepare></action>
- Update: to load one handle in one present handle which is inherited all of the loaded handle
That’s all today. It’s interesting, right? We welcome all your feedbacks and thoughts. Nice code!
2 Comments
Great Articles! Im about to take the magento certification exam in a month. I hope you could give me more tips and reviewers. Thank you and more power! 🙂
Hi,
Thank you very much for your comment. Just follow our next posts in Magento Certificate Preparation Material series. I think you will find a lot of helpful information.
Good luck!