Welcome Guest, Not a member yet? Register   Sign In
Pass current controller to Loader library.
#1

[eluser]Bramme[/eluser]
Hey all,

I'm trying to extend the Loader library a little. I wanna add some functionality that will autoload libraries, EXCEPT for the ones you set in the autoload.php file.

I've got a fair idea of how to approach this, though I'm currently stuck with the following: for this trick to work I need to know what Controller the visitor is currently viewing, to check wether to load a certain library or not.

I've added this piece of code to the Loader library (offcourse in a MY_Loader class), in the _ci_autoloader method:
Code:
if (isset($autoload_exclude))
{
    if (isset($autoload_exclude['libraries']))
    {
        foreach($autoload_exclude['libraries']['load'] as $item)
        {
            if (in_array($current_controller, $autoload['libraries']['exclude'])
            {
                $this->library($item);
            }
        }
    }
}
Offcourse, $current_controller is not set, since I don't know how to get it. I've been digging a bit through the source code, and I suspect the code I need is either in the Router class, or the Controller class. But it's 0:30 am and I'm getting a tad confused.

I was hoping that, when I got up tomorrow, someone could've hinted me in the right direction, so I know where to look.

Thanks in advance!


Messages In This Thread
Pass current controller to Loader library. - by El Forum - 07-30-2008, 04:35 PM
Pass current controller to Loader library. - by El Forum - 07-31-2008, 06:48 AM
Pass current controller to Loader library. - by El Forum - 07-31-2008, 07:58 AM
Pass current controller to Loader library. - by El Forum - 07-31-2008, 08:02 AM
Pass current controller to Loader library. - by El Forum - 07-31-2008, 08:10 AM
Pass current controller to Loader library. - by El Forum - 07-31-2008, 08:18 AM
Pass current controller to Loader library. - by El Forum - 07-31-2008, 08:42 AM
Pass current controller to Loader library. - by El Forum - 07-31-2008, 08:58 AM
Pass current controller to Loader library. - by El Forum - 07-31-2008, 09:26 AM
Pass current controller to Loader library. - by El Forum - 07-31-2008, 02:20 PM
Pass current controller to Loader library. - by El Forum - 07-31-2008, 03:53 PM



Theme © iAndrew 2016 - Forum software by © MyBB