I am working on an application for which i have two types of user in Magento system. Each user can login and reach to their Dashboard. On the user Dashboard depending on what kind of user is logged in, I want to show/hide blocks from layout.

With understanding i have so far, I was able to reach a solution. Where I am adding blocks for both the users in layout update handler and then conditionally based on what kind of user is logged in, I am removing blocks not required for that particular user from layout.

Even though this solution works but i think this isn't the right approach to do the things, as every time i create new controller action I need to put this check and accordingly modify layout.

What can be a better approach to do the same?

1 Answer 1


two layout handle

Add your own layout handle which maps to the customer-type. So you can add the blocks based on the type.

To do this, follow the link to inchoo.


create observer listening on inchoo_controller_action_layout_load_before

class Inchoo_LayoutHandle_Model_Observer
    public function controllerActionLayoutLoadBefore(Varien_Event_Observer $observer)
        /** @var $layout Mage_Core_Model_Layout */
        $layout = $observer->getEvent()->getLayout();

        $type = Mage::getSingleton('customer/session')->getCustomer()->getType();
        $layout->getUpdate()->addHandle('customer_' . $type);

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.