如何创建admin->system->配置菜单在Magento 1.7


How to create admin->system->configuration menu in Magento 1.7?

我有一个模块。这需要管理配置。我不知道如何在admin->system->配置中创建菜单,以及如何将项目添加到自定义菜单....请帮帮我....

它包含4个文件,用于为模块添加新的配置菜单。如果模块已经有一个辅助类Data.php,那么只需要两个xml文件。helper类Data.php可以是空的,它只需要在管理面板中加载新的菜单配置。最重要的两个xml文件是模块etc文件夹中的adminhtml.xmlsystem.xml

adminhtml.xml示例

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <acl>
        <resources>
            <admin>
                <children>
                    <system>
                        <children>
                            <config>
                                <children>
                                    <helloworld_setting>
                                        <title>Hello World</title>
                                    </helloworld_setting>
                                </children>
                            </config>
                        </children>
                    </system>
                </children>
            </admin>
        </resources>
    </acl>
</config>

system.xml示例

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <tabs>
        <helloworld translate="label" module="helloworld">
            <label>Hello World</label>
            <sort_order>99999</sort_order>
        </helloworld>
    </tabs>
    <sections>
        <helloworld_setting translate="label" module="helloworld">
            <label>Settings</label>
            <tab>helloworld</tab>
            <frontend_type>text</frontend_type>
            <sort_order>99</sort_order>
            <show_in_default>1</show_in_default>
            <show_in_website>1</show_in_website>
            <show_in_store>1</show_in_store>
            <groups>
                <greeting_settings translate="label">
                    <label>Greeting Settings</label>
                    <frontend_type>text</frontend_type>
                    <sort_order>1</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <show_in_store>1</show_in_store>
                    <fields>
                        <enabled translate="label">
                            <label>Enabled</label>
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>10</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </enabled>
                        <greeting translate="label,comment">
                            <label>Greeting</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>20</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                            <comment>Greeting text.</comment>
                        </greeting>
                    </fields>
                </greeting_settings>
            </groups>
        </helloworld_setting>
    </sections>
</config>

检索您在配置菜单中设置的值

//sectionName/groupName/fieldName
echo Mage::getStoreConfig('helloworld_setting/greeting_settings/enabled');
echo Mage::getStoreConfig('helloworld_setting/greeting_settings/greeting');

如果有任何问题,请确保在代码更改后清除缓存,并仔细检查xml文件中没有打字错误。