diff --git a/Modules/sections/class.sections.php b/Modules/sections/class.sections.php index 2409b41..3224670 100644 --- a/Modules/sections/class.sections.php +++ b/Modules/sections/class.sections.php @@ -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,14 +88,28 @@ 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) { - $data = array( - 'name' => $name, - 'module_section' => $module_section, - 'module_name' => $module_name, - 'controller_path' => FUZEPATH . $controller_path, - 'model_path' => FUZEPATH . $model_path, - 'view_path' => FUZEPATH . $view_path, - ); + 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, + 'module_name' => $module_name, + 'controller_path' => FUZEPATH . $controller_path, + '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