File tree Expand file tree Collapse file tree 1 file changed +20
-12
lines changed Expand file tree Collapse file tree 1 file changed +20
-12
lines changed Original file line number Diff line number Diff line change 55 A common practice to better distinguish between templates and fragments is to
66 prefix fragments with an underscore. That's why this template is called
77 '_flash_messages.html.twig' instead of 'flash_messages.html.twig'
8+
9+ We check if we have session before reading flashes as it otherwise triggers session start:
10+ https://symfony.com/doc/current/session/avoid_session_start.html
11+
12+ TIP: With FOSHttpCache you can also adapt this to make it cache safe:
13+ https://foshttpcachebundle.readthedocs.io/en/latest/features/helpers/flash-message.html
814#}
915
10- <div class =" messages" >
11- {% for type , messages in app .flashes %}
12- {% for message in messages %}
13- {# Bootstrap alert, see http://getbootstrap.com/components/#alerts #}
14- <div class =" alert alert-dismissible alert-{{ type }} fade in" role =" alert" >
15- <button type =" button" class =" close" data-dismiss =" alert" aria-label =" Close" >
16- <span aria-hidden =" true" >× </span >
17- </button >
16+ {% if app .request .hasPreviousSession %}
17+ <div class =" messages" >
18+ {% for type , messages in app .flashes %}
19+ {% for message in messages %}
20+ {# Bootstrap alert, see http://getbootstrap.com/components/#alerts #}
21+ <div class =" alert alert-dismissible alert-{{ type }} fade in" role =" alert" >
22+ <button type =" button" class =" close" data-dismiss =" alert" aria-label =" Close" >
23+ <span aria-hidden =" true" >× </span >
24+ </button >
1825
19- {{ message | trans }}
20- </div >
26+ {{ message | trans }}
27+ </div >
28+ {% endfor %}
2129 {% endfor %}
22- {% endfor %}
23- </ div >
30+ </ div >
31+ {% endif %}
You can’t perform that action at this time.
0 commit comments