CodeIgniter Forums
MY_Controller problem - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: MY_Controller problem (/showthread.php?tid=24982)



MY_Controller problem - El Forum - 11-26-2009

[eluser]mcair[/eluser]
I am trying to use the constructor of MY_Controller as a gatekeeper. In a derived controller, I get the following message:

Fatal error: Class 'MY_Controller' not found in C:\LeagueManager\Site\system\application\controllers\leaguedisplay.php on line 3

related classes:

Code:
class MY_Controller extends Controller
{
    
function __construct()
{
    parent::Controller();
    if (!f_IsValidSessionValue('OwnerPublicId'))
        $this->load->view('auth/login_form');
}

Code:
class LeagueDisplay extends MY_Controller {
    
function __construct()
{
    parent::MY_Controller();
}



MY_Controller problem - El Forum - 11-26-2009

[eluser]Phil Sturgeon[/eluser]
When you start mixing PHP 4 and PHP 5 style constructors you are gearing up for a headache. I'd set them all to PHP 4 style and see if that helps.


MY_Controller problem - El Forum - 11-26-2009

[eluser]mcair[/eluser]
Thanks for the input. I tried a straight PHP4 approach, renaming the __Construct function to the same as the class, but have the same results.


MY_Controller problem - El Forum - 11-26-2009

[eluser]jedd[/eluser]
Filename and location of your MY_Controller file please.


MY_Controller problem - El Forum - 11-26-2009

[eluser]Phil Sturgeon[/eluser]
To confirm, you have:

Code:
class MY_Controller extends Controller
{
    
function MY_Controller()
{
    parent::Controller();
    if (!f_IsValidSessionValue('OwnerPublicId'))
        $this->load->view('auth/login_form');
}

in application/libraries/MY_Controller.php ?


MY_Controller problem - El Forum - 11-26-2009

[eluser]mcair[/eluser]
Thank-you! I had placed my_controller in \Controllers. Moved it to Libraries and all is well. Thanks again.