}
}
- $contentTemplate = $sidebarTemplate = '';
+ // 1. initialize all boxes first
+ $boxObjects = array(
+ 'content' => array(),
+ 'sidebar' => array()
+ );
foreach ($boxIDs as $boxID) {
$className = $this->boxCache[$boxID]->className;
if (!ClassUtil::isInstanceOf($className, 'wcf\system\dashboard\box\IDashboardBox')) {
$boxObject = new $className();
$boxObject->init($this->boxCache[$boxID], $page);
- if ($this->boxCache[$boxID]->boxType == 'content') {
- $contentTemplate .= $boxObject->getTemplate();
- }
- else {
- $sidebarTemplate .= $boxObject->getTemplate();
- }
+ $boxObjects[$this->boxCache[$boxID]->boxType][] = $boxObject;
+ }
+
+ // 2. fetch all templates
+ $contentTemplate = $sidebarTemplate = '';
+ foreach ($boxObjects['content'] as $box) {
+ $contentTemplate .= $box->getTemplate();
+ }
+ foreach ($boxObjects['sidebar'] as $box) {
+ $sidebarTemplate .= $box->getTemplate();
}
WCF::getTPL()->assign(array(