CodeIgniter Forums
Call to undefined method CI_Controller::Controller() - 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: Call to undefined method CI_Controller::Controller() (/showthread.php?tid=51182)

Pages: 1 2


Call to undefined method CI_Controller::Controller() - El Forum - 04-24-2012

[eluser]yuro[/eluser]
Hello,

I uploaded my CodeIgniter Version to 3.0, because the old version had shown a Error on google.com and now come the next problem:

Error: Call to undefined method CI_Controller::Controller()in /.../frontendcontroler.php on line 20

Thats the code:

Code:
function __construct()
  {
parent::Controller(); //Error
  ....

Where's the problem? I'm using CI3.0


Call to undefined method CI_Controller::Controller() - El Forum - 04-24-2012

[eluser]vrencianz[/eluser]
It looks like you must change parent::Controller()

Code:
public function __construct()
       {
            parent::__construct();
       }



Call to undefined method CI_Controller::Controller() - El Forum - 04-24-2012

[eluser]CroNiX[/eluser]
http://ellislab.com/codeigniter/user-guide/general/controllers.html#constructors


Call to undefined method CI_Controller::Controller() - El Forum - 04-27-2012

[eluser]yuro[/eluser]
I have corrected the error, but i get a new error:

Quote:A PHP Error was encountered

Severity: Notice

Message: Trying to get property of non-object

Filename: libraries/Loader.php

Line Number: 1160


Fatal error: Call to a member function load() on a non-object in ../system/libraries/Loader.php on line 1160

Code:
//Loader.php:

  // Load any custom config file
  if (count($autoload['config']) > 0)
  {
   $CI =& get_instance();
   foreach ($autoload['config'] as $key => $val)
   {
    $CI->config->load($val); //Line 1160
   }
  }

What I must do??


Call to undefined method CI_Controller::Controller() - El Forum - 04-27-2012

[eluser]CroNiX[/eluser]
The problem is in your other custom code, which you didn't post. Post your entire controller that is causing this issue.


Call to undefined method CI_Controller::Controller() - El Forum - 04-27-2012

[eluser]yuro[/eluser]
Code:
Controller.php

class CI_Controller extends CI_Base{

private static $instance;

function Controller()
{
  parent::CI_Base();
}

public function __construct()
{
  self::$instance =& $this;

  // Assign all the class objects that were instantiated by the
  // bootstrap file (CodeIgniter.php) to local class variables
  // so that CI can run as one big super object.
  foreach (is_loaded() as $var => $class)
  {
   $this->$var =& load_class($class);
  }

  $this->load =& load_class('Loader', 'libraries');
  $this->load->initialize();
  log_message('debug', 'Controller Class Initialized');
}

public static function &get;_instance()
{
  return self::$instance;
}
}

Do you mean the Controller.php? Thats the code of the file.


Call to undefined method CI_Controller::Controller() - El Forum - 04-27-2012

[eluser]CroNiX[/eluser]
No, not the CI controller...whatever controller (or whatever code) YOU made.


Call to undefined method CI_Controller::Controller() - El Forum - 04-27-2012

[eluser]yuro[/eluser]
okkk thats my file "frontendcontroler.php":

Code:
class Frontendcontroler extends CI_Controller {
    
var $notifications    = array();
var $mError   = array();
var $mSuccess = array();

var $isLogin = FALSE;

function __construct()
{
  parent::__construct();
  
      $lang = get_languages('data');
      $lang_detection = $lang[0][1];
      
      // set defauld language
  if(!$this->session->userdata('web_lang'))
  {
     var_dump($this->session->set_userdata(array('web_lang' => $lang_detection)));
     $this->config->set_item('language', $lang_detection);
  } else {
     $this->config->set_item('language', $this->session->userdata('web_lang'));    
  }
  
  # LOAD LANGUAGE
  if(!$this->session->userdata('web_lang'))
  {
     $this->lang->load('label', $lang_detection);
     $this->lang->load('error', $lang_detection);
     $this->lang->load('success', $lang_detection);
     $this->lang->load('notes', $lang_detection);
  } else {
     $this->lang->load('label', $this->session->userdata('web_lang'));
     $this->lang->load('error', $this->session->userdata('web_lang'));
     $this->lang->load('success', $this->session->userdata('web_lang'));
     $this->lang->load('notes', $this->session->userdata('web_lang'));    
  }
  
    
      
  #Authorization  
  $params = $this->uri->uri_to_assoc(4);
  $index = false;
  if(isset($params['c_id']) && strtolower($this->uri->segment(2)) == 'content' && $params['c_id'] == 1 )
      {
         $index = true;
      }
      
  if( $this->uri->segment(2) && !$index )
  {
     $this->authorize();    
  }
  
}

/**
  * Function to authorize the user
  * @since 1.0 beta  
  * @return  Boolean
  */
function authorize()
{
    /*
      $this->load->model('mod_user/model_user', 'loginSystem');
            
    if(!$this->loginSystem->isLogin())
    {
       redirect('components/guestbook');      
    }
    */
}

  
/**
  * Allows you to set the pagination settings for all the pages
  * @access protected  
  * @since 1.0 beta
  * @name   paginationSettings
  * @return Array
  */
function paginationSettings($limit, $total_page, $base_url)
{
     #Config For Pagination
       $config['per_page']        = $limit;
     $config['num_links']       = 2;
     $config['prev_link']       = '<<';
     $config['prev_tag_open']   = '<span>';
     $config['prev_tag_close']  = '</span>';
     $config['next_link']       = '&gt;&gt;';
     $config['next_tag_open']   = '<span>';
     $config['next_tag_close']  = '</span>';
     $config['first_link']      = '&lt;';
     $config['first_tag_open']  = '<span>';
     $config['first_tag_close'] = '</span>';
     $config['last_link']       = '&gt;';
     $config['last_tag_open']   = '<span>';
     $config['last_tag_close']  = '</span>';
     $config['num_tag_open']    = '<span>';
     $config['num_tag_close']   = '</span>';
     $config['cur_tag_open']    = '<span id="pagination-current">';
     $config['cur_tag_close']   = '</span>';
    
     $config['total_rows']      = $total_page;
     $config['uri_segment']     = $this->uri->total_segments();
     $config['base_url']        = site_url($base_url);
    
     return $config;
}


}



Call to undefined method CI_Controller::Controller() - El Forum - 04-27-2012

[eluser]CroNiX[/eluser]
I'd start commenting out lines until you find the exact error line. You might also consider not using php4 style property declarations with php5, but that isn't the problem you're having.


Call to undefined method CI_Controller::Controller() - El Forum - 04-28-2012

[eluser]yuro[/eluser]
And what I must do that the programm runs correctly?