• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MY_Controller Not Extending?

#1
[eluser]Unknown[/eluser]
I've looked at this for an hour and I am really miffed. Can someone help me figure out what I'm missing?

I'm trying to extend the CI_Controller to have a method available in all of my other controllers.

I have created MY_Controller.php and placed it in my application/core folder. Here are the contents:

Code:
<?php

class MY_Controller extends CI_Controller {
    
    function __construct()
    {
        parent::__construct();

    }

    function nav_items()
    {
        $nav_items = array();
        
        $nav_items[] = array(
            'title'    => 'Weekly Rundowns',
            'uri'    => 'rundowns/index',
            'class'    => ''
        );
        // if logged in, show more menu options
        if ($this->tank_auth->is_logged_in()) {
            $nav_items[] = array(
                'title'    => 'Assignments',
                'uri'    => 'assignments/index',
                'class'    => ''
            );
            $nav_items[] = array(
                'title'    => 'Workers',
                'uri'    => 'rundowns/index',
                'class'    => ''
            );
            $nav_items[] = array(
                'title'    => 'Tasks',
                'uri'    => 'rundowns/index',
                'class'    => ''
            );
            $nav_items[] = array(
                'title'    => 'Settings',
                'uri'    => 'admin/index',
                'class'    => ''
            );
        }
        return $nav_items;
    }
}

When I try to call my method (nav_items()) from my other controllers, I get an error that says, "Call to undefined method..." I was curious if this meant that my MY_Controller.php file was not getting loaded. I put some code in it that would cause an error and it did. So, it seems like it's getting loaded, but I can't access any of the methods in it.

I tried calling the method using $this->nav_items() and for fun CI_Controller::nav_items() and parent::nav_items().. all don't work.

I feel like I have to be missing something obvious, but can't figure it out...


Thanks for any help.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.