Static custom blocks short-codes are not working in Magento 1.9.2.2

 Buy cheap and genuine Windows 7 product key  |
 Windows 7 Product Key for Windows 32bit/64bit Updated 2016y  |
 Windows 7 Ultimate ISO download  |
 Windows 7 Product Key Generator 32 bit and 64 bit Full  |
 Legit Windows 7 Product Key Online Store, PayPal Support  |
 Windows 7 Ultimate with Service Pack 1 Product Key,Windows 7 Key Sale  |
 Windows 7 Key  |
 Get Free Windows 7 Product Key  |
windows-10-education-key
windows-10-enterprise-key
office-2010-key
windows-7-key-sale
windows-10-home-key
windows-10-activation-key
windows-10-pro-key
office-2016-key
windows-10-key
office-2013-key
windows-10-iso
windows-7-key
windows-10-product-key

Nowadays, most common question asked in magento community or stackexchange are “Static custom blocks short-codes are not working in Magento 1.9.2.2“. This issue arise due to following reason.

1. Update magento version to version 1.9.2.2
2. Installing patch SUPEE-6788

Example : I have include CMS static page as following

{{block type="cms/block" block_id="custom_static_block"}}

After updating this, “custom_static_block” is not displaying in home page. The shortcode also shows PHP error in log file under var folder.

Notice: Undefined variable: block  in /app/code/core/Mage/Core/Model/Email/Template/Filter.php on line xxx

I have checked and found that, All the custom static blocks are now working. This is new security patch SUPEE-6788. Custom static blocks need to added in whitelist.

More details technical regarding SUPEE-6788

The responsible code in Filter.php are given below :

if (isset($blockParameters['type'])) {
  if ($this->_permissionBlock->isTypeAllowed($blockParameters['type'])) {
    $type = $blockParameters['type'];
    $block = $layout->createBlock($type, null, $blockParameters);
  }
} elseif (isset($blockParameters['id'])) {
    $block = $layout->createBlock('cms/block');
    if ($block) {
     $block->setBlockId($blockParameters['id']);
   }
}

Now go to the System=> Permission => Blocks

System-permission->blocks

Simply you need to add block type which you have to add block with shortcode. Click on add new. Set block name Ex. “cms/block” and “is_allowed” to “yes”

System-permission->blocks

Now your static block will be in whitelisted and will be able to show in frontend.
div style=”display:none;”>
cheap football kits  |
cheap football kits  |
cheap football kits  |
cheap football kits  |
cheap football kits  |
cheap football kits  |
cheap football kits  |
cheap football kits  |
cheap football kits  |
cheap football kits  |
cheap football kits  |
cheap football kits  |
cheap football kits  |
cheap football kits  |
cheap football kits  |
cheap football kits  |
cheap football kits  |
cheap football kits  |
cheap football kits  |
cheap football kits  |
cheap football kits  |
cheap football kits  |
cheap football kits  |

Magento2 call cms static block

 Buy cheap and genuine Windows 7 product key  |
 Windows 7 Product Key for Windows 32bit/64bit Updated 2016y  |
 Windows 7 Ultimate ISO download  |
 Windows 7 Product Key Generator 32 bit and 64 bit Full  |
 Legit Windows 7 Product Key Online Store, PayPal Support  |
 Windows 7 Ultimate with Service Pack 1 Product Key,Windows 7 Key Sale  |
 Windows 7 Key  |
 Get Free Windows 7 Product Key  |
windows-10-education-key
windows-10-enterprise-key
office-2010-key
windows-7-key-sale
windows-10-home-key
windows-10-activation-key
windows-10-pro-key
office-2016-key
windows-10-key
office-2013-key
windows-10-iso
windows-7-key
windows-10-product-key

If you want to call cms block in .phtml template file then add below code to your phtml file –

<?php echo $block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('a2bizz_block_identifier')->toHtml();?>

If you want to call cms block in .xml file, then add below code to the layout file –

<referenceContainer name="content">
  <block class="Magento\Cms\Block\Block" name="a2bizz_block_identifier">
   <arguments>
     <argument name="a2bizz_block_id" xsi:type="string">a2bizz_block_identifier</argument>
   </arguments>
 </block>
</referenceContainer>

If you want to call cms block in CMS Page

{{block class="Magento\\Cms\\Block\\Block" block_id="a2bizz_block_identifier"}}

Magento2: Overriding Block

This post go through the process to extend a block in Magento2.

There are a few steps to override a Magento2 block as given below –

Step 1. Building a Magento 2 extension structure

Building directories as following:

magento2 --- app --- code
                       |--- A2bizz --- Sample
                                             | --- Block
                                             | --- etc
                                                    | --- module.xml
                                                    | --- di.xml

Creating module.xml to define a Magento2 extension:

<?xml version="1.0"?>
<!--
/**
 * Created by blog.a2bizz@gmail.com
 */
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
    <module name="A2bizz_Sample" setup_version="0.0.1"/>
</config>

Step 2. Setting preference in di.xml

Creating di.xml to refer the overriding block class:

<?xml version="1.0"?> 
<!-- /** * Created by blog.a2bizz@gmail.com */ --> 
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> 
<preference for="Magento\Theme\Block\Html\Title" type="A2bizz\Sample\Block\HelloTitle" /> 
</config> 

A2bizz\Sample\Block\HelloTitle will be used to override Magento\Theme\Block\Html\Title.

Step 3. Defining an overriding class

Under magento2/app/code/A2bizz/Sample/Block, defining HelloTitle.php as following.

<?php
/**
 * Created by blog.a2bizz@gmail.com
 */
namespace A2bizz\Sample\Block;
use Magento\Framework\View\Element\Template;
class HelloTitle extends \Magento\Theme\Block\Html\Title
{
    public function getPageTitle()
    {
        return 'A2bizz Custom';
    }
    protected function _toHtml()
    {
        $this->setModuleName($this->extractModuleName('Magento\Theme\Block\Html\Title'));
        return parent::_toHtml();
    }
}

HelloTitle.php redefines function getPageTitle() to override the function in \Magento\Theme\Block\Html\Title. The new getPageTitle() just return a text string, but it may also implements a complex logic.

HelloTitle.php also redefines function _toHtml(). Although HelloTitle overrides \Magento\Theme\Block\Html\Title, the template file of \Magento\Theme\Block\Html\Title is still supposed to be used. And the real path of a template file is determined by both the module name of a block and the template attribute of the block. Therefore, the module name of HelloTitle is still Magento_Theme, rather than A2bizz_Sample.

This line

$this->setModuleName($this->extractModuleName('Magento\Theme\Block\Html\Title'));

sets the correct nominal module name. This module name is necessary to render with the template originally defined for Magento\Theme\Block\Html\Title.