Skip to content

Commit

Permalink
adding checks to the route in the module loader so that modules are l…
Browse files Browse the repository at this point in the history
…oaded only where they are set to load in the backend [#106]
  • Loading branch information
dogmatic69 committed Jan 22, 2010
1 parent a5487ba commit 61b2b6a
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions extensions/libs/views/helpers/infinitas.php
Expand Up @@ -13,20 +13,33 @@ function loadModules($position = null){
$modules = ClassRegistry::init('Management.Module')->getModules($position);

$out = '<div class="modules '.$position.'">';
$currentRoute = Router::currentRoute();

foreach($modules as $module){
$out .= '<div class="module '.$module['Module']['module'].'">';
$moduleOut = '<div class="module '.$module['Module']['module'].'">';
if ($module['Module']['show_heading']) {
$out .= '<h2>'.__($module['Module']['name'],true).'</h2>';
$moduleOut .= '<h2>'.__($module['Module']['name'],true).'</h2>';
}

if (!empty($module['Module']['module'])) {
$View = ClassRegistry::getObject('view');
$out .= $View->element('modules/'.$module['Module']['module']);
$moduleOut .= $View->element('modules/'.$module['Module']['module']);
}
else if (!empty($module['Module']['content'])) {
$out .= $module['Module']['content'];
$moduleOut .= $module['Module']['content'];
}
$moduleOut .= '</div>';

if (!empty($module['Route']) && is_object($currentRoute)){
foreach($module['Route'] as $route){
if ($route['url'] == $currentRoute->template) {
$out .= $moduleOut;
}
}
$out .= '</div>';
}
else if (empty($module['Route'])) {
$out .= $moduleOut;
}
}
$out .= '</div>';

Expand Down

0 comments on commit 61b2b6a

Please sign in to comment.