Take the 2-minute tour ×
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It's 100% free, no registration required.

Which rules exist?

Is it just a question of configuration?

Can I manipulate it?

Is the order relevant (which I have seen with the Layoutviewer module)?

share|improve this question
    
Are you talking about layout handles? If yes please update your question to clarify that. –  Matthias Zeis Aug 7 at 11:27
    
Did that. Are there any other handles in Magento? With which could they get confused? –  robsch Aug 8 at 7:07
    
There is nothing else called "handles" by Magento but you would be wondering how creative people can get with words when they try to describe things. ;-) I was pretty sure you were talking about layout handles butI didn't want to edit the question without asking you. –  Matthias Zeis Aug 8 at 7:32

2 Answers 2

To get Handels used in the current page, try this

Mage::app()->getRequest()->getLayout()->getUpdate()->getHandels();
share|improve this answer
    
My question was not which handles does a request takes into account. My question was about how does this get determined. –  robsch Aug 7 at 6:30

You should start looking at the method Mage_Core_Controller_Varien_Action::loadLayout.

If you don't specify a parameter to it the <default> handle will be loaded.
Then the action layout will be added.
That is determined based on the module, controller and action.
If your url is module/controller/action then the handle <module_controller_action> will be loaded.
If the controller contains an underscore it will not affect the mapping.
so module/some_controller/action translates to the handle <module_some_controller_action>.

Of course there are some requests that have additional handles loaded via controller or helper.

Let's take for example the category view page. Beside the action handle <catalog_category_view> magento also load <catalog_category_default> or <catalog_category_layered> depending if the category is marked as anchor or not. <catalog_category_layered_nochildren> is also loaded if the category does not have child categories. To get a clear view take a look at Mage_Catalog_CategoryController::viewAction and Mage_Catalog_Model_Category::getLayoutUpdateHandle.

For products the layout handle PRODUCT_TYPE_{typehere} is loaded. Where {typehere} is the product type (simple, configurable, ...). For this see Mage_Catalog_Helper_Product_View::initProductLayout.

And one last thing. If a layout handle contains this node as a child <update handle="other_handle"> then the handle other_handle will be loaded.

share|improve this answer
    
Thank you so far. I see now that some handles are added automatically (default, by-update handles) and some programmatically (in the action method). Is this correct? Further question: on the start page (in a newly created shop instance), where does 'cms_page' come from? Why is it additional to cms_index_index handle? –  robsch Aug 7 at 9:54
    
cms_index_index is the handle for the index page. The homepage request maps the the cms module , index controller, index action. cms_page does not get loaded automatically. It is loaded when viewing a cms page. Check Mage_Cms_Helper_Page::_renderPage. That's where it is used. –  Marius Aug 7 at 10:15
    
Yeah, I see it. renderPage is called by the index action. That's no magic, it's just logical. Even 'default' is added explicitely - until now I though this handle would automatically added to all requests. That's not the case as it seems. Thanks. –  robsch Aug 8 at 7:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.