Welcome Guest, Not a member yet? Register   Sign In
HMVC problem with routes
#1

Here's an example of something that routes from the module do not work for example with /app/modules/mymodul/config/routes.php

routers work in /app/config/routes.php

I tried various solutions that were offered but each had some kind of disadvantages for example.

/app/config/rout.php

PHP Code:
$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;
        }
    }

here it is minus the next, if we have such routes


PHP Code:
$route['admin'] = 'admin/index';
$route['admin/(:any)'] = 'admin/index/$1';
$route['admin/(:any)/(:any)'] = 'admin/index/$1/$2';
$route['admin/(:any)/(:any)/(:num)'] = 'admin/index/$1/$2/$3'

and it turns out that for some reason the first parameter does not understand, for example, we have the address such as / admin / users, then it does not see this users parameter


here is my function that takes parameters

http://prntscr.com/rhrcrs

and it turns out that this method does not see the first parameter; for some reason, the inscription Index will fall into it everywhere as the name of the method, and I can’t understand why this happens.
Reply
#2

If I'm not mistaken you should reverse your route. If I guess your problem correctly. :-)

PHP Code:
$route['admin/(:any)/(:any)/(:num)'] = 'admin/index/$1/$2/$3'
$route['admin/(:any)/(:any)'] = 'admin/index/$1/$2';
$route['admin/(:any)'] = 'admin/index/$1';
$route['admin'] = 'admin/index'
Reply




Theme © iAndrew 2016 - Forum software by © MyBB