CodeIgniter Forums
Extending CI_Controller issues - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Extending CI_Controller issues (/showthread.php?tid=63880)



Extending CI_Controller issues - mr_pablo - 12-18-2015

I am in the process of moving form CI2 to CI3.

In my app, I have my own extended Controller library, extending CI_Controller.

It is actually extended twice, Front_Controller extends MY_Controller, wich extends CI_Controller.

This allowed me to have shared data in MY_Controller and then some user specific stuff in Front_Controller. This worked well in CI2.

But now in CI3, I am having issues with implenting a global data array that I can use to, for example, put data into a view.

It looks like using parent::__construct() is the problem, and my controller, which uses Front_Controller, is loading its view before grabbing data from the construct method in Front_Controller, which gives me "Undefined variable" errors.

So, in CI3, how can I get my extended Controller library to get global data from the construct method before attempting to load the view?