1

我正在努力创建我的第一个社区扩展。这是一个非常简单的,并且已经在工作。我想了解如何将我的扩展添加到管理区域,以允许客户禁用或启用它。我需要在我的模块中添加什么才能做到这一点?任何帮助都会很棒!

这是我的代码:

应用程序/etc/modules/config.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
    <Module_Name>

        <!-- Whether our module is active: true or false -->
        <active>true</active>

        <!-- Which code pool to use: core, community or local -->
        <codePool>community</codePool>

    </Module_Name>
</modules>
</config>

等/system.xml

<?xml version="1.0"?>
<config>
<sections>
    <module translate="label" module="modulename">
        <label>Your Module Name</label>
        <tab>tab_id_where_you_want_to_add_your_section</tab>
        <frontend_type>text</frontend_type>
        <sort_order>980</sort_order>
        <show_in_default>1</show_in_default>
        <show_in_website>1</show_in_website>
        <show_in_store>0</show_in_store>
        <groups>
            <modulename>
                <label>Your Group Title</label>
                <sort_order>10</sort_order>
                <show_in_default>1</show_in_default>
                <show_in_website>1</show_in_website>
                <show_in_store>0</show_in_store>
                <fields>
                    <comment translate="label comment">    
                        <label>Your Field Title</label>
                        <comment>Your Comment</comment>    
                        <frontend_type>text</frontend_type>
                        <sort_order>10</sort_order>
                        <show_in_default>1</show_in_default>
                        <show_in_website>1</show_in_website>
                        <show_in_store>0</show_in_store>
                    </comment>
                </fields>
            </modulename>
        </groups>
    </your_module>
</sections>
</config>

等/adminhtml.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
<menu>
    <modulename translate="title" module="shipping">
        <title>Module</title>
        <sort_order>15</sort_order>
        <children>
            <modulename translate="title" module="modulename">
                <title>Drop Down Shipping</title>
                <sort_order>1</sort_order>
                <action>adminhtml/shipping/index</action>
            </example>
        </children>
    </modulename>
</menu>

    <layout>
        <updates>
            <modulename>
                <file>shipping.xml</file>
            </modulename>
        </updates>
    </layout>
  <acl>
    <resources>
        <admin>
            <children>
                <system>
                    <children>
                        <config>
                            <children>
                                <modulename translate="title" module="shipping">
                                    <title>Your Module Name</title>
                                </modulename>
                            </children>
                        </config>
                    </children>
                </system>
            </children>
        </admin>
    </resources>
  </acl>

</config>

等/config.xml

<?xml version="1.0" encoding="UTF-8"?>

<config> 
<modules>
    <Module_Name>

        <version>0.0.1</version>

    </Module_Name>

</modules>

<frontend>
    <layout>
        <updates>
            <modulename>
                <file>shipping.xml</file>
            </modulename>
        </updates>
    </layout>
</frontend>

<global>
    <helpers>
        <modulename>
            <class>Module_Name_Helper</class>
        </modulename>
    </helpers>
</global>

</config>

我的主题布局 XML 文件:

<?xml version="1.0"?>

<layout version="0.1.0">

<checkout_cart_index>
<reference name="head">
    <action method="addCss"><stylesheet>css/module/shipping.css</stylesheet></action> 
</reference>
<reference name="checkout.cart.shipping">
 <action method="setTemplate"><template>module/shipping.phtml</template></action>
</reference>
</checkout_cart_index> 

</layout>

助手/Data.php

<?php

class Module_Name_Data extends Mage_Core_Helper_Abstract
{

}
4

2 回答 2

0

System >> Configuration >> ADVANCE >> Advance 中已经存在启用和禁用模块功能。

顺便说一句,如果您想在系统 >> 配置页面中添加菜单,本文可能会对您有所帮助http://alanstorm.com/custom_magento_system_configuration

如果出现错误,请再次检查一切是否正常。

于 2012-12-14T13:12:03.147 回答
0

如果您想将节点添加到主管理菜单(带有飞出子菜单的水平菜单)或System\Configuration屏幕侧边栏菜单,您的问题还不是很清楚。以下是如何将部分、组和字段添加到 Magento 配置屏幕的说明。

首先,您需要将etc/system.xml文件添加到模块中:

<?xml version="1.0"?>
<config>
    <sections>
        <your_module translate="label" module="your_module_shortcode">
            <label>Your Module Name</label>
            <tab>tab_id_where_you_want_to_add_your_section</tab>
            <frontend_type>text</frontend_type>
            <sort_order>980</sort_order>
            <show_in_default>1</show_in_default>
            <show_in_website>1</show_in_website>
            <show_in_store>0</show_in_store>
            <groups>
                <your_group_name>
                    <label>Your Group Title</label>
                    <sort_order>10</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <show_in_store>0</show_in_store>
                    <fields>
                        <your_field_name translate="label comment">    
                            <label>Your Field Title</label>
                            <comment>Your Comment</comment>    
                            <frontend_type>text</frontend_type>
                            <sort_order>10</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>0</show_in_store>
                        </your_field_name>
                    </fields>
                </your_group_name>
            </groups>
        </your_module>
    </sections>
</config>

然后将以下部分添加到您的etc/adminhtml.xml. 它将您新创建的部分添加到 ACL,以便您能够控制可以访问它的管理员角色:

<config>
    <acl>
        <resources>
            <admin>
                <children>
                    <system>
                        <children>
                            <config>
                                <children>
                                    <your_module translate="title" module="your_module_shortcode">
                                        <title>Your Module Name</title>
                                    </your_module>
                                </children>
                            </config>
                        </children>
                    </system>
                </children>
            </admin>
        </resources>
    </acl>
</config>
于 2012-12-14T06:09:47.613 回答