The way Magento loads the layout starts when the controller serving the current request calls to:
$this->loadLayout();
This call starts the process of compiling and generating all the blocks that will be used in a later phase to generate the current page contents. The process of geting the proper nodes from the layout requires the following steps:
- Get the layout handles to use
- Get the layout portions to this handles
- Merge the layout handles requested
If we look at the contents of the method loadLayout
, we’ll see this:
public function loadLayout($handles = null, $generateBlocks = true, $generateXml = true) { // This takes the custom handles we pass through the call to the method // as a parameter. This handles are added to the actual handles corresponding // the current page if (false!==$handles && ''!==$handles) { $this->getLayout()->getUpdate()->addHandle($handles ? $handles : 'default'); } // This adds some handles depending on the page we are rendering. We'll se below. $this->addActionLayoutHandles(); . . . more code . . . }
If we look at the method addActionLayoutHandles we’ll see most of the handles used for a particular call:
public function addActionLayoutHandles() { $update = $this->getLayout()->getUpdate(); // // This adds the 'per store' handle, which will look like STORE_en // if you named the stores with the associated language code $update->addHandle('STORE_'.Mage::app()->getStore()->getCode()); // This a 'per theme' handle, and looks like // THEME_frontend_<package-name>_<theme-name> $package = Mage::getSingleton('core/design_package'); $update->addHandle( 'THEME_'.$package->getArea().'_'.$package->getPackageName().'_'.$package->getTheme('layout') ); // Finally, Magento adds the controller-action handle. If we are // loading a category page, this will look like: // catalog_category_view (module_controller_action) $update->addHandle(strtolower($this->getFullActionName())); return $this; }
So the method addActionLayoutHandles
is the one we were looking for.
Hey! Qué opinas sobre el artículo?