0

Hello,

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

Here is my controller method:

<?php
class NameSpace_Module_IndexController extends Mage_Core_Controller_Front_Action
{
    public function IndexAction()
    {
        $this->loadLayout();
        $this->renderLayout();
    }
}

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.

1

Frontend layout file as below

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

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, privacy policy and cookie policy

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