gpt4 book ai didi

php - Magento:如何在 CMS 页面中包含 php 调用

转载 作者:可可西里 更新时间:2023-11-01 00:05:47 25 4
gpt4 key购买 nike

按照本页的说明操作:

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

1) 我在 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,其中包含以下内容:

<?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,其中包含以下内容:

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

最后4) 我进入一个 cms 页面,通过将这个值放入来查看它是否有效:

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

这行代码应该返回特定产品的库存状态(在本例中为 ID 为 02 的产品)

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

最佳答案

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

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

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

关于php - Magento:如何在 CMS 页面中包含 php 调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17144908/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com