how to i pass variables from a controller to a view (tpl) file in OpenCart?
i have coded a custom module so i need to pass the the returned status to the view.
below is a part of my controller where i load the tpl (its a huge function, i have copied only the required block)
$message = '';
if (isset($_POST['server_response'])) {
$message .= 'Server Says= ' . $_POST['server_response'] . "
";
}
if (isset($_POST['output'])) {
$message .= 'Output= ' . $_POST['output'] . "
";
$this->data['msg'] = $message;
$this->data['continue'] = $this->url->link('checkout/success');
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/success.tpl')) {
$this->template = $this->config->get('config_template') . '/template/payment/success.tpl';
} else {
$this->template = 'default/template/payment/success.tpl';
}
$this->children = array(
'common/column_left',
'common/column_right',
'common/content_top',
'common/content_bottom',
'common/footer',
'common/header'
);
$this->response->setOutput($this->render());
}
in my success.tpl when i echo $msg
it says:
Notice: Undefined variable: msg in C:\wamp\www\site\catalog\view\theme\hype\template\payment\success.tpl on line 16
can someone tell how can i pass the $msg variable from the controller to the tpl?