Magento - 如何创建新的管理页面

时间:2015-02-06 20:49:43

标签: magento adminhtml

我正在使用Magento 1.9.0.1,我创建了一个新的扩展程序,我在管理面板中添加了一个新标签,看看图片。

enter image description here

以下是我文件中的内容。

在:/app/code/community/VivasIndustries/SmsNotification/etc/config.xml:

<?xml version="1.0"?>
<config>
  <modules>
    <VivasIndustries_SmsNotification>
      <version>0.1.0</version>
    </VivasIndustries_SmsNotification>
  </modules>
  <global>
    <models>
        <smsnotification>
            <class>VivasIndustries_SmsNotification_Model</class>
        </smsnotification>
    </models>  
    <events>
        <sales_order_save_after>
            <observers>
                <vivasindustries_smsnotification>
                    <class>smsnotification/observer</class>
                    <method>orderSaved</method>
                </vivasindustries_smsnotification>
            </observers>
        </sales_order_save_after>
    </events>
    <helpers>
        <smsnotification>
            <class>VivasIndustries_SmsNotification_Helper</class>
        </smsnotification>
        <adminhtml>
            <rewrite>
                <data>VivasIndustries_SmsNotification_Helper_Adminhtml_Data</data>
            </rewrite>
        </adminhtml>
    </helpers>
  </global>
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <VivasIndustries_SmsNotification before="Mage_Adminhtml">VivasIndustries_SmsNotification_Adminhtml</VivasIndustries_SmsNotification>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>
</config>  

以下是我所拥有的:/app/code/community/VivasIndustries/SmsNotification/etc/adminhtml.xml:

<?xml version="1.0"?>
<config>
    <menu>
        <vivassms translate="title" module="smsnotification">
            <title>SMS Center</title>
            <sort_order>110</sort_order>
            <children>
                <sendsms translate="title" module="smsnotification">
                    <title>Send SMS</title>
                    <action>adminhtml/magesms_sendsms</action>
                    <sort_order>1</sort_order>
                </sendsms>
                <settings>
                    <title>Settings</title>
                    <action>adminhtml/system_config/edit/section/vivas/</action>
                    <sort_order>10</sort_order>
                </settings>
                <about translate="title" module="smsnotification">
                    <title>About</title>
                    <action>adminhtml/smsnotification_about</action>
                    <sort_order>11</sort_order>
                </about>
            </children>
        </vivassms>
    </menu>
    <acl>
        <resources>
            <admin>
                <children>
                    <vivassms>
                        <title>SMS</title>
                        <children>
                            <sendsms translate="title" module="smsnotification">
                                <title>Send SMS</title>
                            </sendsms>
                            <settings>
                                <title>Settings</title>
                                <children>
                                    <smsprofile translate="title" module="smsnotification">
                                        <title>Edit user account</title>
                                    </smsprofile>
                                </children>
                            </settings>
                            <about translate="title" module="smsnotification">
                                <title>About</title>
                            </about>
                        </children>
                    </vivassms>
                    <system>
                        <children>
                            <config>
                                <children>
                                    <vivassms translate="title" module="smsnotification">
                                        <title>Vivas SMS</title>
                                    </vivassms>
                                </children>
                            </config>
                        </children>
                    </system>
                </children>
            </admin>
        </resources>
    </acl>
</config>

我已将这三个子标签添加到创建的新标签SMS Center但是当我点击About标签时,我的错误404 ON MY FRONTEND。这很尴尬。为什么我被重定向到前端?

您能帮我在管理面板中创建一个简单的新自定义页面,我想添加一个简单的文字吗?

提前致谢!

1 个答案:

答案 0 :(得分:2)

似乎Magento认识到你的模块正在告诉它&#34;检查我admin&#34;控制器,但Magento找不到任何东西。找出Magento认为应该命名控制器文件的最佳方法(以及它应该位于哪个文件夹中)是为_validateControllerClassName添加一些临时调试

protected function _validateControllerClassName($realModule, $controller)
{
    $controllerFileName = $this->getControllerFileName($realModule, $controller);
    if (!$this->validateControllerFileName($controllerFileName)) {
        var_dump($controllerFileName);  //add this line    
        return false;
    }

这将转储Magento检查控制器的每个文件。查找包含模块名称的行,并比较文件所在的位置与Magento认为应该位于的位置之间的路径。