1

I developed an extension for EE2 much earlier for parsing template to send the content to an email address. Now I am porting it for EE3 and facing problem that instead of returning parsed template content, its being outputted to browser. Here is the code:

private function _get_template($temp_id, $tdata)
{
    foreach($tdata as $key => $val){
        if(is_array($val)) unset($tdata[$key]);
    }

    $q = ee()->db->select('template_data')
                    ->from('templates')
                    ->where('template_id', $temp_id)
                    ->where('site_id', $this->site_id)
                    ->get();

    $temp = $q->row('template_data');

    if ( !class_exists('EE_Template') )
    {
        require_once APPPATH . 'libraries/Template' . EXT;
    }

    //ee()->TMPL = new EE_Template();

    $s = ee()->TMPL->parse_variables_row($temp, $tdata);

    ee()->TMPL->parse($s, FALSE, $this->site_id);

    $final_template = ee()->TMPL->final_template;

    $temp_content = ee()->TMPL->parse_globals($final_template);

    return $temp_content;
}

Could anyone please help what I am doing wrong.

Your Answer

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

Browse other questions tagged or ask your own question.