Welcome Guest, Not a member yet? Register   Sign In
[Help]Why CI canot support this style of controller?
#1

[eluser]Unknown[/eluser]
I know CI can support this UIR, [admin] is a sub-folder

application/controllers/admin/login.php

But, it can't support, [system] also is a sub-folder...

application/controllers/admin/system/user.php

Please give me a hand...thanks...
#2

[eluser]theprodigy[/eluser]
by default, CI only accepts one level of sub folders. There are threads on here about extending it (which I urge you to look up), but the way I found that works is

1. Create MY_Router.php in your application/libraries folder
2. Create class definition extending CI_Router (class MY_Router extends CI_Router)
3. Open Router.php in your system/libraries folder and copy the entire _validate_request($segments) function (starts around line 190)
4. Paste the function inside of MY_Router class
5. Add
[code]
while(count($segments) > 0 && is_dir(APPPATH.'controllers/'.$this->directory.$segments[0]))
{
// Set the directory and remove it from the segment array
$this->set_directory($this->directory . $segments[0]);
$segments = array_slice($segments, 1);
}
[\code]
in between
[code]
// Set the directory and remove it from the segment array
$this->set_directory($segments[0]);
$segments = array_slice($segments, 1);
[\code]
and
[code]
if (count($segments) > 0)
{
// Does the requested controller exist in the sub-folder?
if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$segments[0].EXT))
{
show_404($this->fetch_directory().$segments[0]);
}
}
[\code]
6. Save MY_Router.php
#3

[eluser]Unknown[/eluser]
Thanks. I have do that like this. Please download the attach file.

^_^




Theme © iAndrew 2016 - Forum software by © MyBB