Magento News

 

Magento createBlock method not working, displaying static block data

Hi,

Ok so Ive created static blocks in my CMS area, and Im trying to output them inside of a custom homepage template Ive built.

Every document I can find says to output the block as follows

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

That didnt work for me, so then I tried another way. —

       <?php $block = Mage::getSingleton('core/layout')->createBlock('cms/block')->setBlockId('my-block-identifier');
        echo $block->toHtml();

All the sites referencing this tell me to use the actual blocks identifier to get the block. So then I decide to manually lookup the block_id in my cms_block table and see if using the block_id number in place of the literal my-block-identifier name will work – and it did. So I am confused… Can anyone tell me how I can get the block by the actual identifier, or look up the blocks id by the identifier so that I can grab the block by block name?

Any help much appreciated.

Magento createBlock method not working, displaying static block data

Possibly Related Posts:


 

Leave a Reply