¿Es posible acceder directamente al parámetro de ruta en la plantilla twig?
Un elemento view en mi página depende de un parámetro de ruta y representará algo si un parámetro de ruta está presente. ¿Es posible acceder directamente al parámetro de ruta en la plantilla twig?
Por ejemplo:
TestBundle_testroute:
pattern: /{name}
defaults: { _controller: TestBundle:Default:test, name: defaultname }
Me gustaría poder acceder directamente al parámetro de ruta "name" en Twig. Algo como:
{{ routing.name }}
35
Author: Elnur Abdurrakhimov, 2011-12-25
2 answers
Puedes lograrlo así:
{{ app.request.get('name') }}
95
Author: Elnur Abdurrakhimov,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-12-25 17:21:38
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-12-25 17:21:38
También estoy teniendo el mismo problema. Para solucionar este problema, primero volcé el objeto de solicitud y revisé los atributos. En atributos puede ver todas las propiedades disponibles asociadas con la solicitud a las que puede acceder twig. Por ejemplo
app.request.attributes('_route'); //gives you route name
app.request.attributes('slug'); //gives you path variable with in the controller with the name 'slug'
0
Author: msucil,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-11-07 11:30:58
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-11-07 11:30:58