Render Template Blocks in Custom WYSIWYG

When developing admin models that have CMS capabilities, it’s likely that you’ll want to use Magento’s WYSIWYG editor in a similar manner to static blocks and CMS pages. By that I mean if you choose to embed a template file to run PHP scripts, you can do so using code similar to this:

{{block type=”core/template” template=”page/html/hello.phtml”}}

This is only possible if you render your content using a method in the CMS Helper called getBlockTemplateProcessor(). Like a fresh can of Ronseal it does exactly what it says on the tin and allows you to process template blocks in your content.

$processor = Mage::helper('cms')->getBlockTemplateProcessor();
$html = $processor->filter($this->getContentArea());

The result of using this is demonstrated below:

Differences using getBlockTemplateProcessor()
Differences using getBlockTemplateProcessor()

* Remember, don’t ever call your content areas ‘content’ or your WYSIWYG editor will blow up.

Hope this helps someone, thanks for reading!