class: center, middle # Magento Layout XML ### MUG ′s Hertogenbosch --- # Layout XML Definitions: * Blocks * Handles * Actions on blocks * Updates --- # Loading a block ```xml
``` --- # Block attributes * type = core/template (Mage_Core_Block_Template) * as = custom alias * before / alias = alias or - * template = PHTML template to override block default --- # Referencing a block (1) ```xml
``` --- # Referencing a block (2) ```xml
myfoobar.phtml
``` --- # Referencing a block (3) ```xml
``` --- # Adding CSS or JS (1) ```xml
skin_css
css/foobar.css
js
foobar/js
``` --- # Adding CSS or JS (2) Methods of head block: * addItem * removeItem Type parameter: * js * css * skin_js * skin_css --- # Loading jQuery from Google CDN ```xml
]]>
``` --- # Handles ```xml
..
..
``` --- # Update handles Call one handle from within another handle: ```xml
``` --- # Inserting a handle Observer method: ```php $layout = Mage::app()->getLayout(); $layout->getUpdate()->addHandle('foobar'); ``` XML layout: ```xml
``` --- # Using unsetChild ```xml
breadcrumbs
``` --- # PHP calls ```php Mage::app()->getLayout()->getUpdate()->getHandles() ``` Events: * controller_action_layout_generate_blocks_before --- # Questions & tools * Is block object loaded when XML defines it, but PHTML does not? Useful tools * Alan Storms CommerceBug * AclReload * AOE Layout Manager