创建magento 1.8自定义模块 [英] create magento 1.8 custom module

查看:66
本文介绍了创建magento 1.8自定义模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须为magento 1.8编写一个自定义登录模块,我是magento的新手,在谷歌搜索后,我发现

I have to write a custom login module for magento 1.8, I'm new to magento and after googling I found this tutorial, but there is a big problem
After creating module when I want to load my own page, 404 error occurs
I can't found anything on magento documentations, please help

这是我的代码:

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

/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

/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

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

class Test_Mymodule_IndexController extends Mage_Core_Controller_Front_Action 
{ 

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

推荐答案

最后,我发现问题出在哪里,整个问题与xml文件中区分大小写的单词有关.
通过用config.xml文件中的<Mymodule>替换<mymodule>来解决我的问题,最后的config.xml看起来像这样

Finally I found where is the problem, the whole problem is about case-sensitive words in xml files
my problem is solved simply by replacing <mymodule> by <Mymodule> in config.xml file and the final config.xml looks like this

<?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配置

I really hate magento xml configurations

Thx为Zvonimir

Thx to Zvonimir

这篇关于创建magento 1.8自定义模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆