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

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -