dongzhe3573 2013-06-04 04:57
浏览 31

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

I have a module. That need admin configuration. I don't know how to create menu in admin->system->configuration and how to add items to that custom menu.... please help me....

  • 写回答

1条回答 默认 最新

  • dqpdb82600 2014-08-12 00:47
    关注

    It involves 4 files for adding a new configuration menu for your module. If your module already have a helper class Data.php, then only two xml files are needed. The helper class Data.php can be empty, it just have to be there for loading your new menu configuration in the admin panel. The most import two xml files are adminhtml.xml and system.xml files in your module's etc folder.

    A sample 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>
    

    A sample 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>
    

    To retrieve the values you set in the configuration menu

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

    If there is any problems, make sure the cache is cleared after the code changes, and double check there is no typos in the xml files.

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度