If no section
request parameter is present, the currently active section is simply the first one in the ordered list of system.xml sections.
This happens in Mage_Adminhtml_Block_System_Config_Tabs::initTabs()
.
(I have removed parts of the method for the sake of clarity!)
public function initTabs()
{
$current = $this->getRequest()->getParam('section');
$configFields = Mage::getSingleton('adminhtml/config');
$sections = $configFields->getSections($current);
$sections = (array)$sections;
usort($sections, array($this, '_sort'));
foreach ($sections as $section) {
if ((empty($current) && $sectionAllowed)) {
$current = $code;
$this->getRequest()->setParam('section', $current);
}
// ... leave out the rest of the method ...
The _sort()
callback method simply sorts the sections by <sort_order>
value.
So which section is sorted first?
As it happens, thats the <paypal>
section, which is configured in Mage/PaypalUk/etc/system.xml!
This section has no <sort_order>
node, so it is sorted to the top.
But, you may ask yourself, why isn't the section shown?
Well, the section configuration is not only missing the <sort_order>
declaration, it is also missing the <show_in_default>
, <show_in_website>
and <show_in_store>
settings.
And the default, if these are not set explicitly to be visible, is to hide the part of the user interface (code found in Mage_Adminhtml_Block_System_Config_Form::_canShowField()
).
If we where to add <show_in_default>1</show_in_default>
to the <paypal>
section, the default page would no longer be empty, it would show the Website Payments Pro (Payflow Edition) group.
If you want a different section to show up as the default, just give it a <sort_order>
that sorts before an empty string ;)
In previous versions of Magento the <paypal>
section had a sort order set, and - if no custom module messed it up - the default section would be the General section from the Mage/Core/etc/system.xml file.
I believe (but don't know) that the current behavior with the blank page is a bug.
A tab does not appear if you don't have sections in it (most probably).
Add a section with at least a group and a field in it.
[EDIT]
Here is my system.xml
that worked:
<?xml version="1.0"?>
<config>
<tabs>
<test_module translate="label" module="test_module">
<label>Test Module</label>
<sort_order>999</sort_order>
</test_module>
</tabs>
<sections>
<test_module translate="label" module="test_module">
<label>Test</label>
<tab>test_module</tab>
<frontend_type>text</frontend_type>
<sort_order>400</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<groups>
<settings translate="label">
<label>Settings</label>
<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>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>
</fields>
</settings>
</groups>
</test_module>
</sections>
</config>
Best Answer
The first section to show up is the one with the lowest sort order. If you have the following code in your system.xml:
Then your section will be displayed first because "10" is the lowest sort_order of any section in the system (at least in a standard Magento shop).