我正在尝试从一个动作挂钩中检索一个值,以显示在管理页面中。
public function hookActionProductCancel($params)
{
$this->response = "response";
}
public function hookDisplayAdminOrder($params) {
$this->context->smarty->assign('response', $this->response);
return $this->display(__FILE__, 'views/templates/admin/response.tpl');
}
我在response.tpl中没有收到“ response”值。可能是个小问题,但我目前无法解决问题。
任何指导都值得赞赏。谢谢。
答案 0 :(得分:1)
您应该只将响应存储到cookie并在显示之前清除它。
public function hookActionProductCancel($params)
{
// code
$this->context->cookie->mymodule_response = "response";
$this->context->cookie->write();
}
public function hookDisplayAdminOrder($params)
{
// if no response stored in cookie do nothing
if (!$this->context->cookie->mymodule_response) {
return false;
}
// assign response from cookie to smarty then clear response from cookie
$this->context->smarty->assign('response', $this->context->cookie->mymodule_response);
unset($this->context->cookie->mymodule_response);
return $this->display(__FILE__, 'views/templates/admin/response.tpl');
}
答案 1 :(得分:0)
您忘记使用this
public function hookActionProductCancel($params)
{
..... codes .....
$this->response = "response";
}
public function hookDisplayAdminOrder($params)
{
$this->context->smarty->assign('response', $this->response);
return $this->display(__FILE__, 'views/templates/admin/response.tpl');
}