CodeIgniter Forums

Full Version: MY_Controller problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[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();
}

El Forum

[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.

El Forum

[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.

El Forum

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

El Forum

[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 ?

El Forum

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