magento - 创建管理员控制器

时间:2015-07-21 12:37:53

标签: magento

我有一个管理模块Siteadmin_Approval - 这是confing.xml -

<config>
    <modules>
        <Siteadmin_Approval>
            <version>1.4.0</version>
        </Siteadmin_Approval>
    </modules>

    <frontend>
        <routers>
            <approval>
                <use>standard</use>
                <args>
                    <module>Siteadmin_Approval</module>
                    <frontName>approval</frontName>
                </args>
            </approval>
        </routers>
        <layout>
            <updates>
                <approval>
                    <file>approval.xml</file>
                </approval>
            </updates>
        </layout>        
    </frontend>
    <admin>
        <routers>
            <approval>
                    <use>admin</use>
                    <args>
                        <module>Siteadmin_Approval</module>
                        <frontName>approval</frontName>
                    </args>
            </approval>
        </routers>
    </admin>
    <adminhtml>
        <menu>
            <approval module="approval">
                <title>Companies</title>
                <sort_order>71</sort_order>
                <children>
               <sub_menu1 translate="title">
                    <title>Registered Comapnies</title>
                    <sort_order>10</sort_order>
                    <action>approval/adminhtml_approval</action>
               </sub_menu1> 
                </children>
            </approval>
        </menu>
        <acl>
            <resources>
                <admin>
                    <children>
                        <approval translate="title" module="approval">
                            <title>Payment Requests</title>
                            <sort_order>50</sort_order>
                            <children>
                                <items module="uploads">
                                    <title>Requests</title>
                                    <sort_order>0</sort_order>
                                    <action>uploads/adminhtml_uploads</action>
                                </items>
                            </children>
                        </approval>
                    </children>
                </admin>
            </resources>
        </acl>
        <layout>
            <updates>
                <uploads>
                    <file>approval.xml</file>
                </uploads>
            </updates>
        </layout>

    </adminhtml>
    <global>

        <blocks>
            <approval>
                <class>Siteadmin_Approval_Block</class>
            </approval>
        </blocks>
        <helpers>
            <approval>
                <class>Siteadmin_Approval_Helper</class>
            </approval>
        </helpers>
    </global>
</config>

控制器是 -

<?php

class Siteadmin_Approval_Adminhtml_ApprovalController extends Mage_Adminhtml_Controller_action
{

    protected function _initAction() {
        $this->loadLayout()
            ->_setActiveMenu('siteadmin/approval');

        return $this;
        }


    public function indexAction() { 
        $this->_initAction()
            ->renderLayout();
    }

        public function rejectAction() {

            echo "working"; die;

        }
}

和布局文件approval.xml包含 -

<?xml version="1.0"?>
<layout version="1.4.0">

    <approval_adminhtml_approval_index>
        <reference name="content">
            <block type="approval/adminhtml_approval" name="approval" />
        </reference>
    </approval_adminhtml_approval_index>


    <approval_adminhtml_approval_reject>
        <reference name="content">
            <block type="approval/adminhtml_approval/reject" name="approval" />
        </reference>
    </approval_adminhtml_approval_reject>
</layout>

索引操作正常。但拒绝行动并没有被召唤。如果我打印echo "===>".Mage::getUrl('approval/adminhtml_approval/reject');,则只返回http://example.com/index.php/approval/adminhtml_approval/reject。它不会在网址中生成管理密钥。 我的布局xml有什么问题?

感谢任何帮助。 感谢。

1 个答案:

答案 0 :(得分:0)

实际上除了使用它之外 - Mage::getUrl('approval/adminhtml_approval/reject');

这有效 -

Mage::helper("adminhtml")->getUrl("approval/adminhtml_approval/reject");

配置和布局中的所有设置都是正确的。