问题描述
我正在将我的项目从Symfony 2.0.22升级到2.2.0,并查看一些更改,但是我对此受阻:
I'm upgrading my project from Symfony 2.0.22 to 2.2.0 and review somes changes, but i'm blocked on this :
我想使用其控制器和"render"控件渲染标头(如在Sf 2.0.X中).细枝法对我不起作用.他们是错误:
I would like to render (like in Sf 2.0.X) a header with their controller and the "render" twig method don't work for me. Their is the error :
这是实际的渲染方法:
...
{%渲染"OSSiteBundle:Index:header"与{'thisid':block('thisid'),...}%}
{% render "OSSiteBundle:Index:header" with {'thisid' : block('thisid'), ... } %}
我尝试过:
{{ render('OSSiteBundle:Index:header' , {'thisid' : block('thisid'), 'thistitle' : block('thistitle'), 'thisunderpageid' : block('thisunderpageid'), 'thisbackground' : block('thisbackground') }) }}
{{ include("OSSiteBundle:Index:header.html.twig", {'thisid' : block('thisid'), 'thistitle' : block('thistitle'), 'thisunderpageid' : block('thisunderpageid'), 'thisbackground' : block('thisbackground') }) }}
=>最后一项工作,但Controller没有以这种方式收拾
=> The last one work but the Controller isn't colled in this way
我什至尝试了一个在routing.yml中带有路径的渲染...我没有其他想法可以帮助我!
I tried even a render with a path in routing.yml... I have no other idea help me please!
推荐答案
在Symfony> = 2.2.x中,您应该这样嵌入控制器:
In Symfony >= 2.2.x you should embed your controller like this:
{{ render(controller('AcmeArticleBundle:Article:recentArticles', { 'max': 3 })) }}
看一下文档:
这篇关于如何使用“渲染"在Twig中插入控制器?在Symfony 2.2中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!