• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to access controllers in subdirectories

[eluser]André Padez[/eluser]
Hi everyone,

i am really new to CI, and i was asked to reuse an application that was built last christmas.
I got around most of it, but now i am stuck with what i think should be an easy task.

So, i am working with query strings like:

in my controllers folder, i hava a subfolder called 'backoffice' with three controllers inside. How can i point my url so i can reach 'backoffice/donations.php' ?

thank you in advance

André Alçada Padez

A quick scan of the router library shows that controllers in subdirectories are not supported when using query strings.

This MY_Router extension might fix this. Note: I haven't tested this, and it fails if you include more than 1 directory.
class MY_Router extends CI_Router
     * Set the route mapping
     * This function supports a directory in the controller_trigger string
     * @access    private
     * @return    void
    function _set_routing()
        // Are query strings enabled in the config file?
        // If so, we're done since segment based URIs are not used with query strings.
        if ($this->config->item('enable_query_strings') === TRUE AND isset($_GET[$this->config->item('controller_trigger')]))
            $controller = explode('/', $_GET[$this->config->item('controller_trigger')]);
            if ( count($controller) == 1 )

            if (isset($_GET[$this->config->item('function_trigger')]))
            return parent::_set_routing();

/* End of file MY_Router.php */
/* Location: ./application/libraries/MY_Router.php */

hey this idea did not come in ma mind. i can use this. i will try n tel u later..

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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