I want a 'global link' to each module like this:
Inside application/config/routes.php
$route['search'] = 'searchPage';
if the user is typing search in the url it needs to go to module searchPage, there is where the routes inside the module comes in. Or that's my plan, I want a default routing inside that module.
Inside modules/searchPage/config/routes.php
$route['searchPage'] = 'Welcome/showMessage';
go to the Welcome controller with function showMessage.
-modules
--searchPage
---config
----routes.php
---controllers
---views
---models
inside my Welcome controller:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Welcome extends MX_Controller {
public function showMessage()
{
$this->load->view('test');
}
}
?>
Version: Wiredesignz 5.5 and codeigniter 3.0.3
But this don't work. Can someone explain why this doesn't work?
I found a solution:
I have placed this code in application/config/routes.php
$modules_path = APPPATH.'modules/';
$modules = scandir($modules_path);
foreach($modules as $module)
{
if($module === '.' || $module === '..') continue;
if(is_dir($modules_path) . '/' . $module)
{
$routes_path = $modules_path . $module . '/config/routes.php';
if(file_exists($routes_path))
{
require($routes_path);
}
else
{
continue;
}
}
}
And inside modules/searchPage/config/routes.php
$route['searchPage'] = 'searchPage/Welcome/showMessage';
$route['searchPage'] = 'searchPage/Welcome/showMessage';inside the main ( and should be the only config directory) routes file as I propose on my answer ? - David