这个Magento代码有什么问题? - 简单的例子

时间:2011-04-08 21:22:05

标签: magento

我正在尝试在此网址上关注这个非常受欢迎的教程:http://alanstorm.com/magento_admin_controllers

我尝试了第一次测试 - 在“Testing It Out”下,我没有被重定向到我的登录屏幕,然后被重定向到带有空白页面的控制面板。相反,我得到了......

对网址http://mymagentotest.com/index.php/adminhelloworld/的回复会产生以下消息。我一遍又一遍地尝试这个,每次都得到完全相同的结果 - 这告诉我,我正在学习如何做错,因为我一遍又一遍地犯同样的错误。我需要帮助,或者我们需要帮助,因为我确信我不是唯一的。

  哎呀,我们的坏......你的页面   请求没找到,我们有一个   好猜猜为什么。如果您输入了URL   直接,请确保   拼写是正确的。如果你点击了   到达这里的链接,链接是   过时的。

我看不出有什么问题,一切看起来都很好我的有限知识,我不得不猜测配置文件的结构。我认为这就是问题所在。这是我的代码......

app/code/local/Alanstormdotcom/Adminhelloworld/etc ...

中的配置文件
<config>
<!-- ... -->
<admin>
    <routers>
        <the_name_of_this_element_is_not_important_it_should_be_unique>
            <use>admin</use>
            <args>
                <module>Alanstormdotcom_Adminhelloworld</module>
                <frontName>adminhelloworld</frontName>
            </args>
        </the_name_of_this_element_is_not_important_it_should_be_unique>
    </routers>
</admin>
<!-- ... -->        
</config>

app/code/local/Alanstormdotcom/Adminhelloworld/controllers

中的索引控制器
<?php class Alanstormdotcom_Adminhelloworld_IndexController extends Mage_Adminhtml_Controller_Action
{
    public function indexAction()
    {
        $this->loadLayout();
        $this->renderLayout();
    }
}
Alanstormdotcom_adminHelloworld.xml中的

app/etc/modules ..

<config>
    <modules>
        <Alanstormdotcom_Adminhelloworld>
            <version>0.1.0</version>
        </Alanstormdotcom_Adminhelloworld>
    </modules>
</config>

签名:困惑,感觉注定要失败。我必须尝试学习这些东西,因为我的工作,如果我失败了,我最终会住在巷子里一个漂亮的盒子里。

1 个答案:

答案 0 :(得分:2)

通常,您拥有的两位XML应合并到app/code/local/Alanstormdotcom/Adminhelloworld/etc/config.xml中,而第二个文件app/etc/modules/Alanstormdotcom_adminHelloworld.xml则应该如下所示:

<config>
    <modules>
        <Alanstormdotcom_Adminhelloworld>
            <active>true</active>
            <codePool>local</codePool>
        </Alanstormdotcom_Adminhelloworld>
    </modules>
</config>

虽然看起来对新手来说似乎是一场巨大的艰难挣扎,但你要么掌握它,要么变得更有就业能力,要么学会使用像ModuleCreator这样的自动化工具。无论哪个发生,你都会回过头来想想你是如何挣扎的。

相关问题