• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Controllers in Unlimited Nested Folders

[eluser]Robson Tenório[/eluser]
if you try a path that not exists, CI will redirect you to default controller.
To avoid this edit the code:

        // quick an easy forced reindexing
        $segments = array_values($segments);
              //BEGIN INSERT
        if ($segments == NULL)
            show_error('Path not found');            
          //END INSERT
        // put the entire directory path back into the segment as the first
        $dir = trim($this->directory, '/');

This sounds a great idea, I have wanted to do this and couldn't understand why it wasn't implemented in CI.

Do you think it might get put into CI1.5.5 somehow? It of course would need testing but since it doesn't cut back on functionality only adding, it should be backward compatible.

[eluser]Robson Tenório[/eluser]
I think so Wink
That was an update to code proposed on thread and it solved a little problem.

So pardon my ignorance here...but how exactly do I implement this code?


paste the two code snippets in files with the names of the classes in the application/libraries directory

Two snippets? I only see one in the main post.

there is one on this page, thread n°18


I was using this feature in version 154 with success and exploring 2 levels sub-folder in my CI application. Unfortunately, today I tried to upgrade to version 160 and my second level stop working but the first level still working.

Someone knows what happened?

Thanks in advance.

Hi again,

Its look like we only have to change the name of the method from "_validate_segments" to "_validate_request" in the Router extension. It start working like before. See the code bellow.

function _validate_request($segments) {
   return parent::_validate_request($this->_pluck_directory($segments));

I don't know why they changed the name but they must have a reason.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.