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
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.
-
2From Magento 1.9. this works but don't forget to add cms/block to the allowed blocks (System > Permissions > Blocks).Akif– Akif2017年04月05日 12:58:00 +00:00Commented Apr 5, 2017 at 12:58
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.
-
1Specifically allow
cms/blockunder System -> Permissions -> blocksCollin Anderson– Collin Anderson2017年10月20日 20:27:25 +00:00Commented Oct 20, 2017 at 20:27