【发布时间】:2014-08-13 16:47:16
【问题描述】:
我在将会话变量传递到 exception.html.twig 时遇到问题。 exception.html.twig 的位置是:
\vendor\symfony\symfony\src\Symfony\Bundle\TwigBundle\Resources\views\Exception\exception.html.twig
在控制器中我尝试了这样的事情:
$sess = $this->session->remove('param');
$this->render('TwigBundle:Exception:exception.html.twig', array(
'name' => $sess,
));
在树枝上我试着这样称呼它:
{{ name }}
当我的代码中有 $this->render 时,页面正在加载,正在加载并且不想加载。我该如何解决?
【问题讨论】:
-
您不需要编辑
vendor\symfony\symfony\src\Symfony\Bundle\TwigBundle\Resources\views\Exception\exception.html.twig文件。这是不好的做法。您需要覆盖 twig-template 并将代码放入模板中。如何覆盖模板你可以在这里阅读symfony.com/doc/current/book/… -
1.
$this->session是什么,你怎么样? 2. 你回复了吗? -
感谢您的回复,请问这样的操作怎么做?或者他们有什么方法可以直接从异常控制器中删除会话参数?
-
xurshid29: 1. $this->session 初始化后得到 $this->session = new Session();然后 $this->session->set('param') 在我的控制器中。 2.我返回响应但没有$sess变量,我只想像我写的那样通过render方法将它渲染到视图