【问题标题】:create magento 1.8 custom module创建 magento 1.8 自定义模块
【发布时间】:2014-02-16 09:44:29
【问题描述】:

我必须为 magento 1.8 编写一个自定义登录模块,我是 magento 新手,谷歌搜索后我找到了this tutorial,但是有一个大问题
创建模块后,当我想加载自己的页面时,出现 404 错误
我在magento文档上找不到任何东西,请帮助

这是我的代码:

/app/code/local/Test/Mymodule/etc/config.xml

<?xml version="1.0" encoding="utf-8"?> 
<config>     
    <modules> 
        <Test_Mymodule> 
            <version>0.1.0</version> 
        </Test_Mymodule> 
    </modules> 
     <!-- This node contains parameters, available on frontend --> 
    <frontend> 
        <!-- Module aliases are located in this block --> 
        <routers> 
            <!-- This node's name should be the same as our alias --> 
            <mymodule> 
                <!-- use parameter specifies which of basic routers needs to be used. 
                This can be "standard" for frontend or "admin" for backend --> 
                <use>standard</use> 
                <!-- router arguments block --> 
                <args> 
                    <!-- This parameter specifies the full name of out module --> 
                    <module>Test_Mymodule</module> 
                    <!-- This parameter sets module alias --> 
                    <frontName>mymodule</frontName> 
                </args> 
            </mymodule> 
        </routers> 
      <layout> 
            <updates>                
                <helloworld>                     
                    <file>mymodule.xml</file> 
                </helloworld> 
            </updates> 
        </layout> 
    </frontend> 
</config>  

/app/etc/modules/Test_Mymodule.xml

<?xml version="1.0" encoding="utf-8"?> 
<config>     
    <modules> 
        <Test_Mymodule> 
           <active>true</active> 
           <codePool>local</codePool> 
        </Test_Mymodule> 
    </modules> 
</config> 

/app/code/local/Test/Mymodule/controllers/IndexController.php

class Test_Mymodule_IndexController extends Mage_Core_Controller_Front_Action 
{ 

   public function indexAction() 
    { 
     echo "test"; 
    } 
}

【问题讨论】:

  • 你关闭缓存管理了吗?
  • 是的缓存管理已关闭
  • 那么你必须粘贴你的代码...
  • 我将代码粘贴到哪里?我在开始编写模块之前以及在配置中显示该模块名称之后关闭了缓存,但不起作用
  • @ZvonimirBurić 我粘贴了我的代码

标签: php magento magento-1.8


【解决方案1】:

最后我发现问题出在哪里,整个问题是关于 xml 文件中区分大小写的单词
我的问题只需在config.xml 文件中将&lt;mymodule&gt; 替换为&lt;Mymodule&gt; 即可解决,最终的config.xml 看起来像这样

<?xml version="1.0" encoding="utf-8"?> 
<config>     
    <modules> 
        <Test_Mymodule> 
            <version>0.1.0</version> 
        </Test_Mymodule> 
    </modules> 
     <!-- This node contains parameters, available on frontend --> 
    <frontend> 
        <!-- Module aliases are located in this block --> 
        <routers> 
            <!-- This node's name should be the same as our alias --> 
            <Mymodule> 
                <!-- use parameter specifies which of basic routers needs to be used. 
                This can be "standard" for frontend or "admin" for backend --> 
                <use>standard</use> 
                <!-- router arguments block --> 
                <args> 
                    <!-- This parameter specifies the full name of out module --> 
                    <module>Test_Mymodule</module> 
                    <!-- This parameter sets module alias --> 
                    <frontName>mymodule</frontName> 
                </args> 
            </Mymodule> 
        </routers> 
      <layout> 
            <updates>                
                <helloworld>                     
                    <file>mymodule.xml</file> 
                </helloworld> 
            </updates> 
        </layout> 
    </frontend> 
</config>   

我真的很讨厌 magento xml 配置

感谢兹沃尼米尔

【讨论】:

  • 实现这一点需要多少时间?
  • @Chester 大约 6 天
  • 我知道那种感觉:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-02-16
  • 2012-09-07
  • 1970-01-01
相关资源
最近更新 更多