Skip to content

Instantly share code, notes, and snippets.

@splacento-incomm
Last active October 4, 2016 12:02
Show Gist options
  • Save splacento-incomm/3dd35539fb80c8ddbe57d1017852e92d to your computer and use it in GitHub Desktop.
Save splacento-incomm/3dd35539fb80c8ddbe57d1017852e92d to your computer and use it in GitHub Desktop.
Magento load static block into any template
//please use layout xml for loading static blocks.. But if you just want to echo some html or something like that without editing xml;
$block = Mage::getModel('cms/block')->setStoreId(Mage::app()->getStore()->getId())->load('static_block_name');
echo $block->getTitle();
echo $block->getContent();
or
echo Mage::app()->getLayout()->createBlock('cms/block')->setBlockId('some_block_id')->toHtml();
@splacento-incomm
Copy link
Author

$this->getLayout()->getBlock('root')->setTemplate('page/homepage.phtml'); //changes the template
$block=Mage::app()->getLayout()->createBlock('cms/block')->setBlockId('identifier_of_static_block');//->toHtml();
$this->getLayout()->getBlock('content')->append($block);

    $this->renderLayout();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment