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

[eluser]Phil Sturgeon[/eluser]
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.


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