CodeIgniter Forums
MY_Controller problem - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: MY_Controller problem (/thread-24982.html)



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.