<? XML version = 1.0 "? <Config> <section> example of implementation example translate = "label"> <label> </label> <tab> General </label> <frontend_type> text </ frontend_type> <sort_order> 1000 </sorting order> <show_in_default> 1 </show_in_default> <strong> 1 </show_in_website> <show_in_store> 1 </show_in_store> </example> </Chapter> </configuration>
Some marked names are allsystem.xml
, Which can be used in these parts, group and field definition:
EXAMPLE
Given a unique name, so it does not cover any other part. In reality, all lowercase names are the first choice.
label
Is the visible segment name.
tab
Is the name of any existing title in the chapter list.
frontend_type
Here is alwaystext
But I am used to using a lot of things.
sort_order
Tab. If the new part is omitted, it is replaced by an additional part.
show_in_default
,show_in_website
&show_in_store
Show or hide (1 or 0) different ranges are selected in the upper left corner of the "current configuration range" drop-down page. If either of them is omitted, it is set to 0.
comment
You can add your own comments to a field or group.
Groupsystem.xml
Use the specific tag name in:
expanded
When a group is expanded, you can view the specific tag by default.
This is because it is a new page and the permissions required for page management. Next, create the fileCompany/Module/etc/adminhtml.xml
.
<? XML version = 1.0 "? <Config> <acl> <resources> <ALL> <TITLE> allow ALL </TITLE> </> use <admin> <children> <SYSTEM> <children> <config> <children> (implementation example: translate = "title">) <TITLE> example section </TITLE> <sort_order> 100 </sort_order> </example> </children> </configuration> </children> </Management> </resource> </ACL> </configuration>
Note:admin
,system
config
The core module has been defined, so there is no need to define a title for these.
If you want to appear in the configuration of some existing modules, and then use its name, it is not redefinedlabel
sort_order
Or any other identifier. The existing part has been granted permissions.
<? XML version = 1.0 "? <Config> <section> <General> lower <! -Here you add: </General> </Chapter> </configuration>
The Group is extended fieldsets in a section, and they are always children in a section. Edit yourCompany/Module/etc/system.xml
File:
<? XML version = 1.0 "? <Config> <section> example of implementation example translate = "label"> <label> </label> <tab> </label> <frontend_type> text </frontend_type> <sort_order> 1000 </sorting order> <show_in_default> 1 </show_in_default> <show_in_website> 1 </show_in_website> <show_in_store> 1 </show_in_store> <groups> <! -Go to the new group-> <frontend_type> text </frontend_type> <sort_order> 100 </frontend_type> of <sample translate = "label"> <label> A </label> /sort_order> <show_in_default> 1 </show_in_default> <show_in_website> 1 </show_in_website> <show_in_store> 1 </show_in_store> </sample> </example> </ chapter> </configuration>
The field is in the same way as the children group, and the group is part of the children.
<? XML version = 1.0 "? <Config> <section> implementation example: translate = ""> <label> </label> <tab> </label> <frontend_type> text </frontend_type> <sort_order> 1000 </sorting order> <show_in_default> 1 </show_in_default> <show_in_website> 1 </show_in_website> <show_in_store> 1 </show_in_store> <groups> <sample translate <frontend_type> text </frontend_type> <sort_order> 100 </sort_order> <show_in_default> 1 </show_in_default> <Show_in_website> 1 </show_in_website> <show_in_store> 1 </show_in_store> <FIELDS> <! -Here is the new field.-> <ENABLED translate = "label comment"> <label> enable </label> <COMMENT> <! [CDATA [this text shows a field under a small arrow. <Span class = "notice"> it can contain HTML format! </SPAN>]> </comment> <frontend_type> select </frontend_type> <source_model> adminhtml/templates </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> </enable> </field> </sample> </example> </Chapter> </configuration>
comment
It is very useful to provide additional instructions or information. Wrap the text in the CDATA tag. If you want to use HTML,Any HTMLYes, but the most common purpose is to create a highlighted span "notification" or "warning" class.
Frontend_typeCan be any category/lib/Varien/Data/Form/Element/
Directory. Here is just a few:
- Button
- Check box
- Check box
- Day
- File
- Hidden
- Image File
- Image
- Tag
- Link
- Multiple rows
- Multiple choice
- Note:
- Dark lines
- Password
- Radio
- Radio
- Reset
- Select
- Submit
- TEXTAREA
- Text
- Time
Oppositefrontend_type
You can also specify a typical block namemodule/path_to_file
Format. This block will have_getElementHtml()
Method call. Use this field to control the returned HTML.Even if it is calledfrontend_model
It is indeed a block.
Provide possible options for all list fieldsMage/Adminhtml/Model/System/Config/Source
The directory contains many useful sources that have been defined, such as "yes/no", "enable/disable", or you specify a model class. Country, currency, or language list.
You can also create your own source model and typicalmodule/path_to_file
Format. Returns a nested array like this:
<? PHP class Company_Module_Model_Source {public function toOptionArray () {return array (Array ('value' => 0, 'tag' => Mage: helper () -> _ ('first Project'), array ('value' => 1, 'tag' => Mage: helper () -> _ ("item 2") array ('value' => 2, "tag" => Mage: helper () -> _ ("third item ")),//...);}}
The value saved in such a field will contain a string, such as the selected value of '1, 2, 3.
Field Configuration data is usually stored incore/config_data
Model, but you can also define your own. Its_afterLoad()
The method is displayed before the call. It is called_beforeSave()
_afterSave()
Method When you click "Save configuration. When using the data of these events, an additional check may throw an exception in_beforeSave()
Or update the local file in_afterSave()
validate
The label content is added as the final input element of a class. The following is a standard test of Form Verification for Magento.
- Verify administrator password
- Verify Ajax
- Verify-α
- Verify alphanum's
- Verify CC-CVN
- Verify CC-EXP
- Verify the number of milliliters
- Verify milliliters
- Verify CC Selection
- Verify the cleansing URL
- Verification Code
- Verify cpassword's
- Verify CSS Length
- Verify currency USD
- Verify data
- Verification date
- Verification Date: Port-au-Prince
- Verification number
- Verify email
- Verify Fax
- Verification greater than zero
- Verification ID
- Verification Length
- Verify New Password
- Verification without a negative number
- Verification number
- Verification requirements
- Verification requirements by name
- Verify Password
- Verify %
- Verify mobile phone
- Verify Selection
- Verify SSN
- Verification status
- Verify Street
- Verification URL
- Verify the XML identifier
- Verify zero or greater
- Verify zipper
- Verification ZIP Code International
This is very simpleCompany/Module/etc/config.xml
:
<? XML version = 1.0 "? <Config> <DEFAULT> <example> <SAMPLE> set to Enabled 1 </enable> </SAMPLE> </example> </DEFAULT> </configuration>
HereENABLED
Field has been adoptedadminhtml/system_config_source_yesno
The source mode is defined as "no", and the values of '0' and '1' are "yes '. The default value is '1', which means that the enabled domain will be 'yes' until the user changes it.
The fastest way to access the saved field value is as follows:
Mage: getStoreConfig (for example,/sampling/enable ');
section/group/field
The format path is always under consideration.getStoreConfig()
The default value is the website or store range.