I need to add static block which I created from back end to specific pages like user dashboard, login page. Is this possible?
3 Answers
use this where ever you want
call your .phtml file
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('your_block_identifier')->toHtml(); ?>
Yes, it si possible there are two methods
using phtml
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('id-of-cms-block')->toHtml();?>
or using xml
<block type="cms/block" name="layout-name" before="-">
<action method="setBlockId"><block_id>id-of-cms-block</block_id></action></block>
regards
-
-
in this case you should use the xml version and add it int the <reference name="header"> session of you local.xml (please refer to the page.xml for further reference. Or you can take the short path and add the createBlock... instruction in your header.phmtl file– GiuseppeNov 3, 2015 at 11:41
Just place this bit of code on the .phtml
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('your-block-id')->toHtml(); ?>
Replace your-block-id with the block id that you wand to use.