增加Magento后台管理功能三:在后台设置(System/Configuration)中加入自定义设置

在模块的etc目录下新建system.xml配置文件,内容如下:

<?xml version="1.0"?>
<config>
<sections>
<!--要加入的section的标识符,此处为sales, 也可以加入自己的section -->
<sales>
<groups>
<my_settings translate="label">
<label>Settings 1</label>
<frontend_type>text</frontend_type>
<sort_order>500</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>0</show_in_website>
<show_in_store>0</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>0</show_in_website>
<show_in_store>0</show_in_store>
</enabled>
<settings_2 translate="label">
<label>Settings2 </label>
<frontend_type>text</frontend_type>
<sort_order>2</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
</settings_2 >
</fields>
</my_settings>
</groups>
</giftcard>
</sections>
</config>

可以通过Mage::getStoreConfig('[section 标识符]/[group标识符]/[field标识符]')来获取设置的值。
Mage::getStoreConfigFlag方法用来返回bool类型的结果,通过用于开关模块的设置。

如果是自定义section, 则需要在config.xml中加入权限设置:

<acl>
<resources>
<admin>
<children>
<system>
<children>
<config>
<children>
<[自定义section标识符]>
<title>[出现在权限列表中的标题]</title>
</[自定义section标识符]>
</children>
</config>
</children>
</system>
</children>
</admin>
</resources>
</acl>


对于新加入的section,需要后台管理用户重新登录后才能生效。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值