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}}

asked Apr 23, 2014 at 7:45

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.

answered Apr 24, 2014 at 13:51
1
  • 2
    From Magento 1.9. this works but don't forget to add cms/block to the allowed blocks (System > Permissions > Blocks). 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.

answered Sep 25, 2016 at 21:46
1
  • 1
    Specifically allow cms/block under System -> Permissions -> blocks Commented Oct 20, 2017 at 20:27

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.