1

This question already has an answer here:

How to include CMS block in template file(.phtml)

marked as duplicate by Siarhey Uchukhlebau, liyakat, Rajeev K Tomy, Jaimin Sutariya, benmarks Jun 19 '17 at 6:56

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • A simple query on google will give you enormous amount of info. Please do search on google instead of asking here directly. – Rajeev K Tomy Jun 16 '17 at 5:26
4

Use this code to call cms block in phtml file:

<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('block-id-here')->toHtml()?>
3

If you created the cms static block like "my_block_id", Use the below code:

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

You can also do it like this:

<your_layout_handle>
    <reference name="root">
        <block type="cms/block" name="block.name">
            <action method="setBlockId"><block_id>cms_block_id_</block_id></action>
        </block>
    </reference>
<your_layout_handle>

In your phtml you put this where you want to display it:

<?php echo $this->getBlockHtml('block.name') ?>
0

Well this question answered many times in this forum, I dont know why you ask same question again,

but you can try below things.

if your template(PHTML)'s block class extends mage_core_block_template at some where then you can easily use below code

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

IF your Templeate's block class does not extends mage_core_block_template at some point then you can try below code in your phtml file

 <?php echo Mage::app()->getLayout()->createBlock('cms/block')->setBlockId('Your_CMS_Block_Identifier')->toHtml(); ? 
  • Is there any way to fetch the cms block using the "ID" not the identifier ? – Anish Karim Oct 4 '18 at 11:29
  • 1
    @AnishKarim try this <?php echo Mage::app()->getLayout()->createBlock('cms/block')->setId('Your_CMS_Block_Id')->toHtml(); ? – Murtuza Zabuawala Oct 4 '18 at 12:38

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