0

I try to display a custom block in email template and pass the order object. I tried

{{block type='module/blockname' area='frontend' order=$order template='template/module.phtml'}}

Block is like:

Namespace_Module_Block_Blockname extends Mage_Core_Block_Template

The module.phtml exists and using it in another phtml with

Mage::app()->getLayout()->createBlock("module/blockname");

works fine. But in email template the block won't show up. Do i miss some configuration in layout.xml? I tried so many things to get this working, perhaps someone can give me a hint how to manage this.

I also tried with layout handle:

<some_handle>
    <block type="module/blockname" name="blockname" template="namespace/template.phtml"></block>
</some_handle>

and call with:

{{layout area="frontend" handle="some_handle" order=$order}}

2

I know that you can include static blocks using e.g.:

{{block type="cms/block" block_id="static-block-id" }}

That block simply uses _toHtml() to output the content from the static block.

protected function _toHtml()
{
    $blockId = $this->getBlockId();
    ...
    return $html;
}

Similarly, you could try and populate the _toHtml() function with HTML in your module to output what ever you need to output. You cannot use PHP variables such as $order to pass in your data for processing.

  • 2
    From Magento 1.9. this works but don't forget to add cms/block to the allowed blocks (System > Permissions > Blocks). – Akif Apr 5 '17 at 12:58
1

If you are facing the same problem as I am you might have forgotten to white list your block... You need to add an entry in the permission_block table with your block path.

  • 1
    Specifically allow cms/block under System -> Permissions -> blocks – Collin Anderson Oct 20 '17 at 20:27

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.