Magento - {{...}} 占位符在哪里被替换?
我正在创建一些自定义块,并且希望在布局更新 XML 中支持 Magento 的 {{skin url="..."}} 动态占位符功能。
例如:
<action method="setImageSrc">
<name><![CDATA[{{skin url=images/banners/MyBanner.jpg}}]]></name>
</action>
在我的块类中,我获取变量(即 $this->getImageSrc()
),构建 HTML 并输出它。不幸的是,它实际上输出{{skin url="..."}}。该翻译在哪里进行?我可以在输出之前传递 HTML 来清理它吗?如果是这样,怎么办?
注意:我尝试过带或不带 CDATA 以及带或不带引号的 URL。没有任何效果...有些人比其他人更糟糕
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
感谢@clockworkgeek 提供的信息,我已经弄清楚了这一点。这两个资源解释得很好......除了如何使用它。
Magento CMS 语法 Magento CMS 语法
magentocommerce.com/wiki/3_-_store_setup_and_management/cms/markup_tags#how_do_template_tags_work" rel="noreferrer">模板标签如何工作
要实际使用它非常简单。我只是在自定义块类中创建了自己的 _toHtml() 方法,如下所示:
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: