Last active
October 4, 2016 12:02
-
-
Save splacento-incomm/3dd35539fb80c8ddbe57d1017852e92d to your computer and use it in GitHub Desktop.
Magento load static block into any template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$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);