而不是这样渲染我的TWIG中的每个幻灯片(见第6行):
{# loop out the slides #}
{% for c in contents %}
{% set i=i+1 %} {# increase slide number #}
{% endfor %}
相反,我想把所有这些逻辑都保留在控制器中,以便将视图提供给一系列准备好的幻灯片.我该如何做这样的事情(见第9行):
//do stuff...
foreach ($container->getContent() as $c) {
$content[$i]['title'] = $c->getTitle();
$content[$i]['sort'] = $c->getSortOrder();
$content[$i]['data'] = $c->getData();
$content[$i]['template'] = $c->getTemplate()->getId();
$content[$i]['duration'] = $this->extract_seconds($c);
$content[$i]['html'] = $this->render('BizTVArchiveBundle:ContentTemplate:'.$content[$i]['template'].'/view.html.twig', array(
'contents'=> $content[$i],
'ordernumber' => 99,
));
}
所有它现在给我($content [$i] [‘html]]的内容)
{"headers":{}}