我有一些获取参数为?perpage = 10 & category = all & sort = relevance 我想在我的Jtwig代码中读取此参数并将其打印出来。据文件和源代码,我发现这应该工作:Jtwig获取参数显示
{{ app.request.attributes.get('category') }}
或
{{ app.request.query.get('category') }}
,并应在这种情况下打印“所有”,但这些都要求我的机器上返回空字符串。
来源:Twig - Get URL for canonical tag,https://github.com/symfony/symfony/issues/7960。
任何建议或解决方法,将不胜感激。