在Slim中重定向

时间:2016-07-05 09:54:55

标签: ajax twig slim

我有一个ajax请求,但我需要我的响应才能重定向到某个twig模板。这就是我所拥有的:

$response = ['success'=>false]; 
return $this->view->render($resp, 'spotlight-results.twig',['data' => $response] );  

这个问题是我在控制台中接收页面,这不是替换发出请求的页面。我不知道我是否正确地解释了自己......

1 个答案:

答案 0 :(得分:0)

我找到了答案:

 $loader = new Twig_Loader_Filesystem('../templates/');
 $twig = new Twig_Environment($loader);
 $template = $twig->loadTemplate('spotlight-results.twig');
 $message = ['success' => false];
 $view = $template->render(['data' => $message]);
 $response = ['success' => false, 'view' => $view];

这样我就可以使用我想要的内容返回我的模板,$ message