We have a custom third-party module called qo5. All of our controllers are in there.

I have a template that I need to pass a variable from a PHP function to.

{exp:qo5 action="deal/getDealCode"}
    <span>Test: {default_combo_override}</span>

The deal/getDealCode function looks like this:

public function getDealCode() {
        $deal_id = $this->EE->input->post('deal_id');
        $deal_code = $_SESSION['order']['coupons'][$deal_id]['code'];
        error_log("deal code: " . $deal_code);

        if($deal_code == 'GARLICPARM') {
                $data['default_combo_override'] = 'AT';
                error_log(print_r($data, 1));
                return $this->EE->TMPL->parse_variables($this->EE->TMPL->tagdata, $data);

I know it's being called; the error log is executing and displaying the correct data. But the span value for default_combo_override is not being populated.

What am I missing here? We use similar functionality all over the place, and it works everywhere else.

2 Answers 2


The array that you're passing to parse_variables is incorrectly structured - it needs to be one level deeper.

You can fix this either by wrapping it in an array:

return $this->EE->TMPL->parse_variables($this->EE->TMPL->tagdata, array($data));

Or using parse_variables_row instead:

return $this->EE->TMPL->parse_variables_row($this->EE->TMPL->tagdata, $data);

Have you tried putting the parsed_variable into a new variable and then returning that?

$output = $this->EE->TMPL->parse_variables($this->EE->TMPL->tagdata, $data);
return $output ;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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