Magento Shortcode CMS块在产品页面上不起作用 [英] Magento Shortcode CMS block not working on product pages

查看:74
本文介绍了Magento Shortcode CMS块在产品页面上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Magento产品页面上添加CMS块.

I am attempting to add a CMS block on a Magento product page.

我正在使用的简码是:

{{block type="cms/block" block_id="myproductblock"}}

该块显示为文本.它不会插入CMS块.我已确保禁用了所见即所得编辑器.

The block shows up as text. It does not insert the CMS block. I have made sure that the WYSIWYG editor is disabled.

推荐答案

我假设您要将其添加到product.phtml

I assume you want to add it to product.phtml

为此,您需要编辑layout/catalog.xml

To do this, you need to edit the layout/catalog.xml

...
<catalog_product_view>
..
...
<block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">
    <!-- start your code: -->
    <block type="cms/block" name="myproductblock" before="-">
        <action method="setBlockId"><block_id>myproductblock</block_id></action>
    </block>

然后在您的view.phtml中编写:

Then inside your view.phtml you write:

<?php echo $this->getChildHtml("myproductblock") ?>

"myproductblock"与您在layout.xml中指定的名称相同的地方

Where the "myproductblock" is the same as the name you specified inside the layout.xml

此后,您必须清除layout.xml缓存,它应该可以工作:)

After this you have to clear the layout.xml cache and it should work :)

为什么您的代码不起作用: 这些.phtml文件都是php脚本."{{"和}}"必须由模板引擎解释,并且仅在电子邮件,CMS页面/块和后端的所见即所得编辑器内部有效.

Why your code didn't work: Those .phtml files all are php-scripts.. the "{{" and "}}" must interpreted by a template engine and is only valid inside emails, CMS pages/blocks and the wysiwyg editors in the backend.

这篇关于Magento Shortcode CMS块在产品页面上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆