Magentoでカスタムモジュールを作成しましたが、動作しません。Magento 1.9でカスタムモジュールが動作していません
マイモジュールアクティベーションファイルはapp\etc\modules\Knowledge_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\etc\config.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>`
私のコントローラファイルが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();
}
}
マイブロックファイルがapp\code\local\Knowledge\Gain\Block\Trail.php
<?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"?>
<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>`
、テンプレートファイルである私は、このコードで間違ってやっている何\app\design\frontend\rwd\default\template\hello.phtml
<?php
echo $this->getContent();
echo get_class($this);
?>
のですか?ブロックの内容は表示されません。
誰でも助けてください、ありがとうございます。
まず、コードが正しいように見えます。テストするには、レイアウトXMLファイルとテンプレートファイルをbase/defaultディレクトリに移動し、それが動作するかどうかを確認します。 –