Magento管理控制器无法正常工作

时间:2014-11-09 13:34:32

标签: magento controller admin

我是magento的新手,在执行管理员控制器时面临问题。这就是我所做的。

Mailchimp / mailchimpmodule的/ etc / config.xml中

<?xml version="1.0"?>
<config>
<modules>
    <Mailchimp_Mailchimpmodule>
        <version>1.0.0</version>
        <depends>
            <!-- no dependencies -->
        </depends>
    </Mailchimp_Mailchimpmodule>
</modules>
<global>
    <models />
    <blocks />
    <resources />
    <extraconfig />
    <helpers>
        <mailchimpmodule>
            <class>Mailchimp_Mailchimpmodule_Helper</class>
        </mailchimpmodule>
    </helpers>
</global>
<admin>
    <routers>
        <adminhtml>
            <args>
                <modules>
                    <foo_bar before="Mage_Adminhtml">Mailchimp_Mailchimpmodule_Adminhtml</foo_bar>
                </modules>
            </args>
        </adminhtml>
    </routers>
</admin>
<frontend>
    <layout>
        <updates>
            <mailchimpmodule>
                <file>mailchimp.xml</file>
            </mailchimpmodule>
        </updates>
    </layout>       
</frontend> 
</config>

Mailchimp / mailchimpmodule的/ etc / adminhtml.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
<menu>
    <mailchimpmodule module="mailchimpmodule" translate="title">
        <title>Mailchimp</title>
        <sort_order>100</sort_order>
        <children>
            <settings module="mailchimpmodule" translate="title">
                <title>Settings</title>
                <sort_order>1</sort_order>
                <action>adminhtml/settings/index</action>
            </settings>
        </children>
    </mailchimpmodule>
</menu>
<acl>
    <resources>
        <admin>
            <children>
                <settings translate="title" module="mailchimpmodule">
                    <title>Mailchimp</title>
                    <sort_order>100</sort_order>
                    <children>
                        <index translate="title">
                            <title>Settings</title>
                            <sort_order>1</sort_order>
                        </index>
                    </children>
                </settings>
            </children>
        </admin>
    </resources>
</acl>
</config>

Mailchimp / mailchimpmodule /控制器/ adminhtml / IndexController.php

<?php
class Mailchimp_Mailchimpmodule_Adminhtml_SettingsController extends     Mage_Adminhtml_Controller_Action
{  
public function indexAction()
{
    $this->loadLayout()
            ->_addContent(
            $this->getLayout()
            ->createBlock('mailchimp_mailchimpmodule/adminhtml_mailchimpmodule')
            ->setTemplate('mailchimp/form.phtml'))
            ->renderLayout();       
}   
}

我可以在admin中看到MailChimp-&gt;设置选项但是当我点击它时,它显示404未找到。这是被调用的URL:

http://localhost/magento/index.php/admin/settings/index/key/efdd74577eb9cbb46237c3803bc4e29c/

1 个答案:

答案 0 :(得分:1)

您的问题出在admin / routers部分。你有foo_bar的地方应该是你的模块名称。

<admin>
    <routers>
        <adminhtml>
            <args>
                <modules>
                    <Mailchimp_Mailchimpmodule before="Mage_Adminhtml">Mailchimp_Mailchimpmodule_Adminhtml</Mailchimp_Mailchimpmodule>
                </modules>
            </args>
        </adminhtml>
    </routers>
</admin>

另外,你的controllers / adminhtml / IndexController.php应该在一个大写'A'的文件夹中,比如controllers / Adminhtml / IndexController.php。