Magento:如何在CMS页面中包含php调用 [英] Magento: How to include a php call in the CMS pages

查看:78
本文介绍了Magento:如何在CMS页面中包含php调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

按照此页面上的说明进行操作:

Following the instructions from this page:

http://www.magento. cc/how-to-use-php-on-a-cms-page.html

1)我在 app/etc/modules 中声明了该模块:

1) i declared the module in the app/etc/modules :

<?xml version="1.0"?>
<config>
    <modules>
        <Stock_status>
            <active>true</active>
            <codePool>local</codePool>
</Stock_status>
</modules>
</config>

2)然后,我在 app \ code \ local \ Stock \ status \ Custom \ etc 中创建了 config.xml ,其中包含以下内容:

2) Then i created the config.xml in app\code\local\Stock\status\Custom\etc with these contents in it:

<?xml version="1.0"?>
<config>
<global>
<blocks>
<Stock_status>
<class>Stock_status_Block</class>
</Stock_status>
</blocks>
</global>
</config>

3)之后,我在 app/code/local/Stock/status/Custom/Block 文件中创建了 test.php ,其中包含以下内容:

3) afterwards i created a test.php in app/code/local/Stock/status/Custom/Block file with these contents in it:

<?php
class Stock_status_Block_Test extends Mage_Core_Block_Abstract
{
protected function _toHtml()
{
.Mage::helper('customstockstatus')->getListStatus($_product->getId()).
return $html;
}
}

最后 4)我进入cms页面,通过将该值放入以下地址来查看它是否有效:

and finally 4) i went in a cms page to see if it works by putting this value in:

{{block type="Stock_status_Custom/test" ListStatus="02"}}

此行代码应向我返回特定产品的库存状态(在此示例中,ID为02的产品)

This line of code should return me the stock status of a specific product (in this example, the product with the ID 02)

但是它不起作用.我做错了什么?有人可以帮我吗?

BUT it doesn't work. What have i done incorrectly? Can someone please help me?

推荐答案

这些是不必要的工作,您可以通过在cms页面内容中添加以下行来简单地调用php文件

These are an unnecessary works, you can simply call the php file by adding the following line into that cms page content

   {{block type="core/template" template="page/urfile.phtml"}}

然后在页面目录下创建文件

Then create file under the page directory

这篇关于Magento:如何在CMS页面中包含php调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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