Loading an advanced module's model from another advanced module's controller

edited July 2011 in News & Announcements
How to do it properly?
I need to show rows taken from various module's models ... say from the blog module, my own 'twitter' module etc

but if i do

$this->load->module_model('twitter', 'tweets_model');

I get this

An Error Was Encountered

The configuration file development/twitter.php and twitter.php do not exist.

Comments

  • edited 12:59AM
    That's the correct syntax. Are you sure those are related? That error message has to do with loading in a twitter config file. Perhaps you are extending a base controller that is trying to load in that config file?
  • edited 12:59AM
    the controller in which i'm trying to load the models extends Fuel_base_controller
    the twitter model extends Base_module_model
  • edited July 2011
    I found where the problem is,
    Inside my twitter model i'm loading the config
    $this->config->load('twitter');

    but apparently this is not needed at all... but why?

    How do i load the twitter.php config file inside modules/twitter/config then?
  • edited 12:59AM
    Try $this->config->module_load('twitter', 'twitter');
  • edited July 2011
    So basically, it looks like I can't load a config file from the module's model: i have to load it from the controller, then i see no errors...
    But why? It would make total sense that the model loads the config file autonomously ... or am i doing something wrong??

    What the hell i'm pulling my hair on this!!!

    This is the controller OUTSIDE of the 'twitter' module (part of another advanced module)

    require_once(FUEL_PATH.'libraries/Fuel_base_controller.php');
    class Akademie extends Fuel_base_controller {


    function __construct()
    {
    parent::__construct();
    $this->load->module_model('twitter', 'tweets_model');
    }


    function featured()
    {

    $tweets = $this->tweets_model->get_latest_tweets();
    }

    }
    This one gives that damn error!!!
    But if i do the same thing from the 'twitter' controller inside the twitter module, all goes fine...
  • edited 12:59AM
    Solution

    So,
    In the end I moved the $this->config->load calls to the controllers that need to load the model. But I found out that if you want to load the configuration file of a model outside of the current module, you have to add the 4th param to the config->load function like this

    $this->config->load('twitter', FALSE, TRUE, 'twitter');
    which is the 'module' parameter.
    Hope this helps someone...
Sign In or Register to comment.