I\'m a front-end Magento dev, have built quite a few of my own themes and I want to understand Magento\'s XML block positioning better...
I normally use a loca
The before
and after
attributes only work in one of two cases:
core/text_list
block getChildHtml
without any parametersWhen you say
you're telling Magento
Hey Magento, put the
example_block
inside theroot
block.
When you put a number of different blocks inside a parent, those blocks have an implicit order. For template blocks, this order doesn't matter, since those blocks are being explicitly rendered.
getChildHtml('example_block') ?>
However, there's two cases where order matters. First, if you call
getChildHtml() ?>
from a template, then Magento will render all the child blocks, in order.
Secondly, there's a special type of block called a "text list" (core/text_list
/Mage_Core_Block_Text_List
). These blocks render all their children automatically, again in order. The content
block is an example of this
That's why you can insert blocks into content
and they render automatically.
So, in your example above, you're inserting blocks into the root
block. The root
block is a template block whose phtml template uses getChildHtml
calls with explicit parameters. Therefore the before
and after
attributes don't do what you (and many others, including me) wish they did.