Welcome Guest, Not a member yet? Register   Sign In
Autoloading library methods?
#15

[eluser]Wayne Smallman[/eluser]
[quote author="Phil Sturgeon" date="1296517652"]You aren't quite understanding me.

Ok, so for this example the messages are in the admin panel.

Admin_Controller:

Code:
class Admin_Controller extends MY_Controller {

    function __construct()
    {
        parent::__construct();

        $this->data['message_count'] = count($this->message_m->get_all());
    }

}

That makes the data available to any controller that uses Admin_Controller. So now we make our controllers use it:

Code:
class Blog extends Admin_Controller {

    function index()
    {
        $this->load->views('whatever', $this->data);
    }

}

No change to your views, just how the controllers are called. Add a __autoload() function like the article says and you're good to go.[/quote]Hi Phil, I understand you completely; I think it's the other way around.

To use that technique, I would have to remove all of the calls to those views it's replacing, or there would be a mass duplication of navigational devices throughout the entire website. And as I said earlier, I'd still have to perform various checks for those situations where the navigation isn't needed all.

I do remember seeing your article on the "MY_Controller" technique a while ago, and the technique itself struck me as being insubstantial, when there really should be some proper means of not just automatically loading a library or a controller, but of functions, too.

I'll figure something out myself because this technique really isn't viable.


Messages In This Thread
Autoloading library methods? - by El Forum - 01-31-2011, 04:21 AM
Autoloading library methods? - by El Forum - 01-31-2011, 06:45 AM
Autoloading library methods? - by El Forum - 01-31-2011, 06:53 AM
Autoloading library methods? - by El Forum - 01-31-2011, 07:18 AM
Autoloading library methods? - by El Forum - 01-31-2011, 07:42 AM
Autoloading library methods? - by El Forum - 01-31-2011, 07:59 AM
Autoloading library methods? - by El Forum - 01-31-2011, 08:07 AM
Autoloading library methods? - by El Forum - 01-31-2011, 08:11 AM
Autoloading library methods? - by El Forum - 01-31-2011, 09:13 AM
Autoloading library methods? - by El Forum - 01-31-2011, 09:15 AM
Autoloading library methods? - by El Forum - 01-31-2011, 09:23 AM
Autoloading library methods? - by El Forum - 01-31-2011, 09:52 AM
Autoloading library methods? - by El Forum - 01-31-2011, 10:04 AM
Autoloading library methods? - by El Forum - 01-31-2011, 11:47 AM
Autoloading library methods? - by El Forum - 01-31-2011, 12:28 PM
Autoloading library methods? - by El Forum - 01-31-2011, 12:31 PM



Theme © iAndrew 2016 - Forum software by © MyBB