'(:section_uri)/(:page_uri)' => 'web/index',
// $module is retrieved from database $widget = $module.'/web/'.$this->param('page_uri'); $this->response = Request::factory($widget, false)->execute()->response();
// reset the router so only module routes are used \Router::routes = array(); // route the widget request $this->response = Request::factory($widget)->execute()->response();
Harro Verton wrote on Tuesday 28th of June 2011:Should be \Routes::$routes. It's a static class property.
Harro Verton wrote on Tuesday 28th of June 2011:I do something similar, but my modules don't produce pages, only widgets. So by front controller sets up the theme, fetches the defined widgets from the database, launches requests for each of the widgets and passes the result on to the theme template.
public static function add_before($path, $options = null) { if (is_array($path)) { foreach ($path as $p => $t) { static::add_before($p, $t); } return; } $name = $path; if (is_array($options) and array_key_exists('name', $options)) { $name = $options['name']; unset($options['name']); if (count($options) == 1 and ! is_array($options[0])) { $options = $options[0]; } } $route[$name] = new \Route($path, $options); static::$routes = array_merge($route, static::$routes); }
// check if the module has custom routes if (file_exists($modpath .= 'config/routes.php')) { // load and add the routes \Config::load(\Fuel::load($modpath), 'routes', true); // added true, to force reload \Router::add_before(\Config::get('routes')); // now calling add_before instead of add }
// Reverse the file list so that we load the core configs first and // the app can override anything.
Harro Verton wrote on Tuesday 28th of June 2011:Module routes are required to always start with 'modulename/' on the lefthand side. If you have violated that rule, there could be a mixup with your global routes.
It looks like you're new here. If you want to get involved, click one of these buttons!