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 Answers 2

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.

1
  • 2
    From Magento 1.9. this works but don't forget to add cms/block to the allowed blocks (System > Permissions > Blocks).
    – Akif
    Commented Apr 5, 2017 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
  • 1
    Specifically allow cms/block under System -> Permissions -> blocks Commented Oct 20, 2017 at 20:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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