Bugfix where sections does not load correct viewdir and modeldir.
This commit is contained in:
parent
9b3bf5fc20
commit
71547eec26
@ -56,7 +56,8 @@ class Sections extends Module {
|
||||
public function layoutLoadEvent($event) {
|
||||
$layout_name = $event->layout;
|
||||
if ($this->currentSection !== null) {
|
||||
$event->directory = $this->view_path;
|
||||
$section = $this->getSection($this->currentSection);
|
||||
$event->directory = $section['view_path'];
|
||||
}
|
||||
return $event;
|
||||
}
|
||||
@ -70,7 +71,8 @@ class Sections extends Module {
|
||||
public function modelLoadEvent($event) {
|
||||
$model_name = $event->model;
|
||||
if ($this->currentSection !== null) {
|
||||
$event->directory = $this->model_path;
|
||||
$section = $this->getSection($this->currentSection);
|
||||
$event->directory = $section['model_path'];
|
||||
}
|
||||
return $event;
|
||||
}
|
||||
@ -86,6 +88,18 @@ class Sections extends Module {
|
||||
* @param String View_path, where to find the views for this section
|
||||
*/
|
||||
public function addSection($name, $module_section = false, $module_name = null, $controller_path = null, $model_path = null, $view_path = null) {
|
||||
if ($module_section) {
|
||||
$m = $this->core->loadMod($module_name);
|
||||
$m_dir = $m->getModulePath();
|
||||
$data = array(
|
||||
'name' => $name,
|
||||
'module_section' => $module_section,
|
||||
'module_name' => $module_name,
|
||||
'controller_path' => $m_dir . '/Controller/',
|
||||
'model_path' => $m_dir . '/Models/',
|
||||
'view_path' => $m_dir . '/Views/',
|
||||
);
|
||||
} else {
|
||||
$data = array(
|
||||
'name' => $name,
|
||||
'module_section' => $module_section,
|
||||
@ -94,6 +108,8 @@ class Sections extends Module {
|
||||
'model_path' => FUZEPATH . $model_path,
|
||||
'view_path' => FUZEPATH . $view_path,
|
||||
);
|
||||
}
|
||||
|
||||
$this->config->set('sections', $name, $data, $this->getModulePath());
|
||||
}
|
||||
|
||||
@ -154,6 +170,18 @@ class Sections extends Module {
|
||||
return $event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a section file
|
||||
* @access public
|
||||
* @param String section name
|
||||
* @return Array Section
|
||||
*/
|
||||
public function getSection($name) {
|
||||
if (isset($this->cfg->$name)) {
|
||||
return $this->cfg->$name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves section information from the config file
|
||||
* @access public
|
||||
|
Loading…
Reference in New Issue
Block a user