magento web developer

Manchester based Magento and Zend Framework certified developer.

Returning HTML with ajax and layout handles

Not so long ago, when I wanted to serve HTML via ajax, my controller action would look something like this:

$myBlock = $this->getLayout()


However I have since discovered a much better way that is not ignorant to layout handles. With a module/controller/method with layout handle mymodule_index_index you can rewrite the node named ‘root’ as follows:


    <block type="core/template" name="root" output="toHtml" template="mymodule/index.phtml" />