So, in the class
app/code/core/Mage/Adminhtml/Block/System/Config/Tabs.php
There's the following loop in the initTabs
method.
foreach ($sections as $section) {
Mage::dispatchEvent('adminhtml_block_system_config_init_tab_sections_before', array('section' => $section));
$hasChildren = $configFields->hasChildren($section, $websiteCode, $storeCode);
//$code = $section->getPath();
$code = $section->getName();
$sectionAllowed = $this->checkSectionPermissions($code);
if ((empty($current) && $sectionAllowed)) {
$current = $code;
$this->getRequest()->setParam('section', $current);
}
//...
}
If the $current
variable is empty/null, it will be set the first time through the loop. This variable is set at the start of the method
$current = $this->getRequest()->getParam('section');
Which means on the default configuration page, since there's no section
parameter, $current
is empty/null.
So, now we need to figure out why our section nodes are ordered in a particular way. In the same initTabs
method, the sections
nodes are loaded with the following
$sections = $configFields->getSections($current);
Since $current
is null
, this means all system.xml
section nodes are returned. Later in the function, these nodes get cast as an array, and then sorted
$sections = (array)$sections;
usort($sections, array($this, '_sort'));
The sort method looks like this
protected function _sort($a, $b)
{
return (int)$a->sort_order < (int)$b->sort_order ? -1 : ((int)$a->sort_order > (int)$b->sort_order ? 1 : 0);
}
So, if a module section
has a sort order that's less than 10
<sections>
<!-- ... -->
<general translate="label" module="core">
<label>General</label>
<tab>general</tab>
<frontend_type>text</frontend_type>
<sort_order>10</sort_order>
<!-- ... -->
it will be sorted sooner than the general
section, which means it will come first in the $sections
loop, and be chose and the default section.
This includes section nodes that have no sort_order. Module authors can fix this "I was just installed and I get to be displayed first" behavior by explicitly including a sort_order
in their system configuration section, and ensuring it's greater than 10
.