Magento - {{...}} 占位符在哪里被替换?

发布于 2024-12-22 01:48:02 字数 488 浏览 1 评论 0原文

我正在创建一些自定义块,并且希望在布局更新 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

亽野灬性zι浪 2024-12-29 01:48:02

感谢@clockworkgeek 提供的信息,我已经弄清楚了这一点。这两个资源解释得很好......除了如何使用它。

Magento CMS 语法 Magento CMS 语法

magentocommerce.com/wiki/3_-_store_setup_and_management/cms/markup_tags#how_do_template_tags_work" rel="noreferrer">模板标签如何工作

要实际使用它非常简单。我只是在自定义块类中创建了自己的 _toHtml() 方法,如下所示:

public function _toHtml()
{
    $processor = Mage::getModel('core/email_template_filter');
    return $processor->filter(parent::_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:

public function _toHtml()
{
    $processor = Mage::getModel('core/email_template_filter');
    return $processor->filter(parent::_toHtml());
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文