1

Is there a way of writing layout such that all the controllers refering to that layout will automatically display the block's if no specific handle has been defined.

what i actually want is that, Is there any specific handle which acts as default handle such that any URl(handle) that is not specified in the layout will use that as their default..?

ex

<xyz_handle>
   <block type="core/template" name="default" template="def/default.phtml" />

</xyz_handle>

and if i call a handle in my url as aaa_index_index and that this hanle is not defined in our layout file then by default it will use the <xyz_handle> handle .

Is there a way of doing this ?

1
  • Or do you want to define a fallback other than default? If the handle is not present in the layout.xml files, add this handle... Commented Jan 29, 2014 at 9:37

2 Answers 2

1

You can add into the controller your own layout handle like that:

class Namespace_Module_IndexController extends Mage_Core_Controller_Front_Action
{   
    public function indexAction()
    {
        $this->getLayout()->getUpdate()->addHandle('myhandle');
    }
}

The other solution is to use an event controller_action_predispatch and set the the handle in the same way as in the controller itself.

Hope it helps

1

Yes, you can use <default> this is processed first and on every request.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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