we are displaying text field in view page to check COD availability.

enter image description here


echo $this->getLayout()->createBlock('core/template')->setTemplate('checkdelivery/checkdelivery.phtml')->toHtml();

in view.phtml we are calling below file . but i want to call static block identifier [identifier code - check] instead of below file.


<div class="block block-list block-check-delivery">
    <div class="block-title">
        <?php $blockLabel = Mage::getStoreConfig('checkdelivery/general/block_title'); ?>
        <strong><span><?php echo $this->__($blockLabel) ?></span></strong>
    <div class="block-content" >        
            <input name="zipcode" size="17" type="text" id="zipcode" value="<?php echo Mage::getModel('core/cookie')->get('zip'); ?>" maxlength="10" class="input-text" placeholder="<?php echo $this->__('Enter ZIP Code'); ?>"/>
            <button type="button" name="zip-check" title="Check" class="button" id="zip-check" ><span><?php echo $this->__('Check'); ?></span></button>
            <div id="delivery-message"></div>
            <?php $defaultHtml = Mage::getStoreConfig('checkdelivery/general/default_html'); ?>
            <div id="delivery-html"><?php if(Mage::getModel('core/cookie')->get('message')){
    echo Mage::getModel('core/cookie')->get('message');
    $defaultHtml; } ?></div>



    Event.observe('zip-check', 'click', function(event){
        new Ajax.Request("<?php echo $this->getUrl('checkdelivery/index/index') ?>", {
            method: "get",
            parameters: {zipcode : $('zipcode').value },
            onSuccess: function(transport) {
                 var json = transport.responseText.evalJSON();
                 $('delivery-message').setStyle({ color: json.color});

static block code :

<p>{{block type ="core/template" template = "checkdelivery/checkdelivery.phtml"}}</p>

You can use the below code:

in .phtml file :

  echo $this->getLayout()->createBlock('cms/block')->setBlockId('block_identifier')->toHtml(); 

sample :

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

in static block / cms page :

{{block type="core/template" template="checkdelivery/checkdelivery.phtml"}}

| improve this answer | |
  • its not displaying textfield now. i updated the static block code in question. – Baby in Magento Apr 29 '16 at 7:15
  • did you refresh you cache? – Qaisar Satti Apr 29 '16 at 7:20
  • yes deleted cache folder, also removed browser cache. – Baby in Magento Apr 29 '16 at 7:21
  • 1
    {{block type ="core/template" template="checkdelivery/checkdelivery.phtml" }} remove space and check the system->permission ->block it is listed (core/template)? – Qaisar Satti Apr 29 '16 at 7:28
  • 1
    createBlock('Magento\Cms\Block\Block') instead of ->createBlock('cms/block') wordked for me :) Thanks for this tip! – Rustyjim Nov 12 '19 at 10:17

If you have created CMS block named 'block_identifier' from admin panel. Then following will be code to call them in .phtml

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

Clear cache and reload your browser.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.