Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 自定义模块在Magento 1.9中不起作用_Php_Magento 1.9 - Fatal编程技术网

Php 自定义模块在Magento 1.9中不起作用

Php 自定义模块在Magento 1.9中不起作用,php,magento-1.9,Php,Magento 1.9,我已经在Magento中创建了自定义模块,但它不起作用 我的模块激活文件是app\etc\modules\Knowledge\u Gain.xml 下面是我的模块激活码: <?xml version="1.0"?> <config> <modules> <Knowledge_Gain> <active>true</active> <cod

我已经在Magento中创建了自定义模块,但它不起作用

我的模块激活文件是
app\etc\modules\Knowledge\u Gain.xml

下面是我的模块激活码:

<?xml version="1.0"?>
<config>
    <modules>
        <Knowledge_Gain>   
            <active>true</active>  
            <codePool>local</codePool> 
        </Knowledge_Gain>
    </modules>
</config>`
我的控制器文件是
app\code\local\Knowledge\Gain\controllers\IndexController.php

<?php
class Knowledge_Gain_IndexController extends Mage_Core_Controller_Front_Action
{
    public function indexAction()
    {
        echo "Knowledge Gain Activated";
        $this->loadLayout();  
        $this->renderLayout();
    }
}
<?php
class Knowledge_Gain_Block_Trail extends Mage_Core_Block_Template
{
    public function getContent()
    {
        return "Block Activated";
    }
布局文件为
app\design\frontend\rwd\default\layout\gain.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Knowledge_Gain>
            <version>0.1.0</version> 
        </Knowledge_Gain>
    </modules>
    <frontend>
        <routers>
            <gain>
                <use>standard</use>
                <args>
                    <module>Knowledge_Gain</module>
                    <frontName>gain</frontName>
                </args>
            </gain>
        </routers>
        <layout>  
            <updates>
                <gain>
                    <file>gain.xml</file>
                </gain>
            </updates>
        </layout>
    </frontend>
    <global>
        <blocks>
            <gain>
                <class>Knowledge_Gain_Block</class>
            </gain>
        </blocks>
    </global>
</config>`
<?xml version="1.0"?>
<layout version="0.1.0">
    <gain_index_index>
        <reference name="content">
            <block type="gain/trail" name="gain" template="hello.phtml" />
        </reference>
    </gain_index_index>
</layout>` 
我在这个代码中做错了什么?块内容不显示


任何人请帮助我,提前谢谢。

一切都好。我要检查你的模块,它在工作

请清除缓存 系统>缓存管理>单击“刷新Magento缓存”按钮


检查模块后

此模块代码正确。在Magento 1.9.1版或更高版本中,您需要 在管理中添加新块。请遵循以下几个步骤:

步骤1:管理>>权限>>块>>添加新块并保存块


第2步:系统>缓存管理>单击“刷新Magento缓存”按钮。

首先查看您的代码是否正确。要进行测试,请将布局XML文件和模板文件移动到base/default目录中,然后查看它是否有效。
<?php
echo $this->getContent();
echo get_class($this);
?>