One of our main goals in Magento is to provide the maximum flexibility possible for all layers of users and developers that will be working with Magento.
The requirements of having updates possible without breaking existing cutomizations, and being able to create any kind of design and layout, made as come up with a way to create a glue layer between code and templates, which we call layouts.
Layout definitions are XML structures that can be stored as text in files or database. We call them layout updates.
These updates are called on specific events during the application flow.
The most prominent layout update is the “default” one, which is located in “core/default.xml”. This layout is invoked for almost all the pages on the store.
You may find that there are “initLayout.xml” files located in other module folders. These are updating the original “default” layout, specifically for each module.
For example, checkout/initLayout.xml does adds checkout links on top and adds sidebar mini cart on the right column.
Other layout update files are invoked at specific events, like “checkout/cart.xml” is used on the shopping cart page. It does:
- set 1 column layout.
- add shopping cart view block, set template file for it
- add coupon, shipping, cross-sell blocks and set template files for them.
Modules that will be installed later and aware of checkout module will be able to update these layouts WITHOUT changing existing code or layout files, just by adding their own layout updates.
Right now layout updates can create new blocks and perform methods on existing blocks.
We do have future plans to have GUI editor in admin area for layout updates.
Blocks are logical units, and their ultimate goal is to produce a final output, which can be HTML, JS, JSON, XML, or anything else.
Blocks can be nested as far as PHP function nesting configuration permits.
Blocks that extend “core/template” will use templates to generate output.
Other blocks will generate output directly from PHP, unless they employ custom logic involving templates.
You do not HAVE to use layouts to create a store design.
In fact you can create a store with one layout, that contains only root block, and one template file that will include all the child block creation logic.
Although I highly do not recommend this solution.
And no, this is not a standard Zend templating