Skip to content

Commit

Permalink
fixing the module loader for direct loading
Browse files Browse the repository at this point in the history
  • Loading branch information
dogmatic69 committed Jan 18, 2013
1 parent d30b615 commit 4e80452
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions Core/Modules/View/Helper/ModuleLoaderHelper.php
Expand Up @@ -228,27 +228,19 @@ public function loadDirect($module, $params = array()) {
$module = sprintf('modules/%s', $module);

$pluginDir = App::pluginPath($plugin) . 'View' . DS . 'Elements' . DS . $module . '.ctp';
$themeDir = App::themePath($this->theme) . $plugin . 'Elements' . DS . $module . '.ctp';

if (!is_file($pluginDir)) {
if (!is_file($themeDir)) {
if (Configure::read('debug')) {
return sprintf(
'Could not find the module, looking in: <br/>%s<br/>%s',
str_replace(APP, 'APP' . DS, $pluginDir),
str_replace(APP, 'APP' . DS, $themeDir)
);
}
$module = implode('.', array(
$plugin,
$module
));

if (!$this->_View->elementExists($module)) {
$module .= '/module';
if (!$this->_View->elementExists($module)) {
throw new CakeException(__d('modules', 'Error: Could not load module "%s"', $module));
}
}

$module = implode('.', array($plugin, $module));

try{
return $this->_View->element($module, array('config' => $params));
} catch(Exception $e) {
throw new CakeException(__d('modules', 'Error: Could not load module "%s" (%s)', $module, $e->getMessage()));
}
return $this->_View->element($module, array('config' => $params));
}

/**
Expand Down

0 comments on commit 4e80452

Please sign in to comment.