Welcome Guest, Not a member yet? Register   Sign In
Codeigniter - Can only load model in autload.php
#2

[eluser]Unknown[/eluser]
After many hours of test and messing up with everything, INCLUDING configuration files... I DID IT!

It was something totally above models and controllers, it was something about the hooks I called. In fact, I have a hook called languageloader.php written like this:

Code:
class LanguageLoader extends CI_Controller {
     public function initialize() {
      $ci =& get_instance();
      $site_lang = $ci->session->userdata('site_lang');
      if (!empty($site_lang)) {
       $ci->lang->load('text', $site_lang);
      } else {
       $ci->lang->load('text', 'english');
      }
     }
    }

In my hooks file it was loaded like:

Code:
$hook['post_controller_constructor'] = array(
     'class'    => 'LanguageLoader',
     'function' => 'initialize',
     'filename' => 'languageloader.php',
     'filepath' => 'hooks',
    );

Since I was using **post_controller_constructor**, referring to CI doc files it is

Quote:Called immediately after your controller is instantiated, but prior to any method calls happening.

I believe that doing something like my $ci =& get_instance(); I couldn't instance my damn model. I fixed it by changing the hook to

Code:
$hook['pre_controller']

I didn't think it could have been something about the hooks and that was the reasons why I didn't post it. Thanks to everyone who tried to help me out in the while. I hope this helped someone else who was in my same trouble!


Messages In This Thread
Codeigniter - Can only load model in autload.php - by El Forum - 10-26-2014, 02:18 PM
Codeigniter - Can only load model in autload.php - by El Forum - 10-26-2014, 04:14 PM



Theme © iAndrew 2016 - Forum software by © MyBB