4

I have a model (core_model.php) with lots of functions in there, however having an issue with the following one in specific :

 Class core_model {
    function __construct(){
        $this->EE =& get_instance();
        $this->EE->load->library('api'); 
        $this->EE->load->library('email');
        $this->EE->load->library('template');

        $settings = $this->_get_settings();
    }

        .....

    function parse_user_template($data)
    {
     $td = $this->EE->db->select("template_data")
                            ->from("templates")
                            ->where("template_name","user_notification")  
                            ->get()->row()->template_data;

     $parsed_data = $this->EE->TMPL->parse_variables_row($td,$data);
    }
}

Basically, I'm calling the $this->EE->core_model->parse_user_template($data) function passing in a $data array of values which I want it to parse against the specific template file for me to do something with once parsed (namely to use it as an email body).

For some reason, I'm getting the following error:

Message: Undefined property: EE::$TMPL

Filename: models/core_model.php

Line Number: 69

Anyone have any ideas why this is the case and I can't parse it?

4

The loading of the template needs to be done as follows:

$this->EE->load->library('template',null,'TMPL');

Now it works.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.