4

I'm creating some custom blocks and I want to support the {{skin url="..."}} dynamic placeholder features of Magento inside the Layout Update XML.

Ex:

<action method="setImageSrc">
    <name><![CDATA[{{skin url=images/banners/MyBanner.jpg}}]]></name>
</action>

Inside my block class I grab the variables (i.e. $this->getImageSrc()), build the HTML, and output it. Unfortunately, it's literally outputting {{skin url="..."}}. Where does that translation get performed? Is that something I can just pass my HTML through to clean it up before outputting? If so, how?

NOTE: I've tried with and without CDATA as well as with and without quotes around the URL. Nothing works...some break it worse than others

Mageician
  • 2,918
  • 9
  • 43
  • 69
  • 1
    your block class could also build the URL, any helper too. Do you really need to put it in the layout file ? –  Dec 20 '11 at 20:36
  • 1
    See http://www.magentocommerce.com/wiki/3_-_store_setup_and_management/cms/markup_tags#how_do_template_tags_work – clockworkgeek Dec 20 '11 at 20:41
  • Worked like a champ! I'm going to create an answer for this based on what I've found. Thanks for your help! Oh, and Vince, I am putting it in the layout file because I have multiple banners and using the layout update XML is so much easier than multiple CMS Static blocks. – Mageician Dec 20 '11 at 21:20

1 Answers1

5

Thanks to the information from @clockworkgeek I have figured this one out. These 2 resources explain it very well...except how to use it.

Magento CMS Syntax

How Do Template Tags Work

In order to actually use this it is VERY simple. I simply made my own _toHtml() method in my custom block class as follows:

public function _toHtml()
{
    $processor = Mage::getModel('core/email_template_filter');
    return $processor->filter(parent::_toHtml());
}
Mageician
  • 2,918
  • 9
  • 43
  • 69