我是Magento的新手。我正在嘗試開發一個自定義模塊。我的代碼如下初級講座第一個Magento模塊開發
地點: d:\ PHP \ htdocs中\ Magento的\ APP \等\模塊
Remote_Mouse.xml
<?xml version="1.0"?>
<config>
<modules>
<Remote_Mouse>
<active>true</active>
<codePool>local</codePool>
</Remote_Mouse>
</modules>
</config>
地點: d:\ PHP \ htdocs目錄\ Magento的\ APP \代碼\本地\遠程\鼠標\等 config.xml中
<?xml version="1.0"?>
<config>
<global>
<modules>
<Remote_Mouse>
<version>0.1.0</version>
</Remote_Mouse>
</modules>
<blocks>
<mouse>
<class>Remote_Mouse_Block</class>
</mouse>
</blocks>
</global>
<frontend>
<layout>
<updates>
<mouse module="Remote_Mouse">
<file>Remote_Mouse.xml</file>
</mouse>
</updates>
</layout>
<routers>
<mouse>
<use>standard</use>
<args>
<module>Remote_Mouse</module>
<frontName>remote</frontName>
</args>
</mouse>
</routers>
</frontend>
</config>
地點:
D:\php\htdocs\magento\app\design\frontend\my_theme\default\layout
mouse.xml
<?xml version="1.0"?>
<layout version="0.1.0">
<reference name="root">
<action method="setTemplate">
<template>page/1column.phtml</template>
</action>
</reference>
<mouse_index_index>
<reference name="content">
<block type="remote/brush" template="remote/mouse.phtml" />
</reference>
</mouse_index_index>
</layout>
地點:D:\php\htdocs\magento\app\code\local\Remote\Mouse\Block
Brush.php
<?php
class Remote_Mouse_Block_Brush extends Mage_Core_Block_Template
{
public function myfunction()
{
echo 'mouse';
}
}
地點:D:\php\htdocs\magento\app\code\local\Remote\Mouse\controllers
IndexController.php
<?php
class Remote_Mouse_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
$this->loadLayout(array('default'));
$this->renderLayout();
}
public function sayHelloAction()
{
echo 'Hello one more time...';
}
}
?>
地點:
d:\ PHP \ htdocs中\ Magento的\ APP \設計\前臺\ my_theme \ DEFAULT \模板\遠程
mouse.phtml
<?php
echo $this->myfunction();
?>
我看不到任何輸出。我的代碼中是否有任何錯誤?
您的所有文件完整路徑應包括在內,尤其是你的回覆XML –
@RobbieAverill感謝。我添加了文件的位置。謝謝 –