I have created one static block. I want to display data from that static block in my controller method.

Here is my controller method:

class NameSpace_Module_IndexController extends Mage_Core_Controller_Front_Action
    public function IndexAction()

If I write following line in controller method:

<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('block_identifier')->toHtml(); ?> 

then static block data is displaying above the header.

I want to show that static block content should come after header part.

  • add your frontend layout file Commented Feb 28, 2016 at 7:33

2 Answers 2


Frontend layout file as below

<layout version="0.1.0">
        <reference name="content">
            <block type="modulename/index" name="example" />

I would strongly suggest you to refrain from doing that, Controllers responsibility should be to manage the application flow rather than literally building up the response to be sent back.

What I would do in your case is append the CMS block by using Layout Update XMLs for your specific NameSpace_Module module.

Look for the proper layout handle to hook up to (probably *_index) and from the XML file (after configuring it as layout_update in the config.xml of your module) append the CMS block referencing any of the blocks of the page layout depending on where you precisely want it to display in the page design.

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.