Sunday, January 12, 2014

#magento | Call Statics Bllock in a .phtml file

Problem:
You would like to add a Static Block, that you can define inside "CMS" -> "Static Block" on another page or section that are not included in your template. 

Solution:
There are various ways to call your static blocks to your Magento fronted but that is one of the best ways to add it in the .phtml and xml files. just follow the nest steps:

1.- Create a CMS Static Block at "CMS"->"Statick Block"->"Add new block"

2.- Add the next sentence inside -phtml
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId(cms_test_block)->toHtml() ?>

for example, if you need to add some Statick block inside the Copyright, you have to edit the next .phtml like this:

Path:
/httpdocs/p/app/design/frontend/base/default/template/page/html

Edit:
<div class="footer-container">
    <div class="footer">
        <?php echo $this->getChildHtml() ?>
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId(CopyRight)->toHtml() ?>
    </div>
</div>


No comments:

Post a Comment