Add Content In Magento Controller

If you want to add content to the rendered page inside a controller action, you can do it like that:

$this->loadLayout();
$message =  $this->getLayout()
            ->createBlock('core/text', 'ready-block')
            ->setText('<h1>Testaction for Controller:</h1>');
$this->getLayout()->getBlock('content')->insert($message);
$this->renderLayout();

 

Leave a Reply

Your email address will not be published.

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.