symfony - How to check app.request.attributes.get('_route')==blog/slug variables -
for eg if url is
http://localhost/project/blog can check current url routes
{% if app.request.attributes.get('_route') == 'blog' %} </p>this default page</p> {%endif%}
but below url:
http://localhost/project/blog/2
not working
{% if app.request.attributes.get('_route') == 'blog/2' %} </p>this blog page 2</p> {%endif%}
try app.request.requesturi: should return "project/blog/2"
{% if 'blog/2' in app.request.uri %} </p>this blog page 2</p> {% endif %}
Comments
Post a Comment