Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
From testing another Bartik issue I noticed that the content looked like it had too big a space above it. Turns out it's an empty messages wrapper printing on the page.
<div id="messages">
<div class="section clearfix"></div>
</div>
Bartik's page.html.twig does have an if statement to print the messages section or not....
{% if messages %}
<div id="messages">
<div class="section clearfix">{{ messages }}</div>
</div>
{% endif %}
But this obviously does nothing and I can't figure out why....
Proposed resolution
The messages section should only print when there are messages printing.
Remaining tasks
Write a patch
Review the patch
Screenshots.
User interface changes
none
API changes
none
Comment | File | Size | Author |
---|---|---|---|
#1 | 2426343-1.png | 486.27 KB | dmitrii |
#1 | 2426343-1.patch | 2.88 KB | dmitrii |
Screen_Shot_2015-02-13_at_17_09_13_1.png | 468.04 KB | emma.maria |
Comments
Comment #1
dmitrii CreditAttribution: dmitrii commentedIt's because
{{ messages }}
is{"#theme":"status_messages","#access":true}
so it is always true.Looks like we should use system template status-messages.html.twig if we want to save
Comment #2
idebr CreditAttribution: idebr commented{{ if messages }}
should be the correct syntax, but currently doesn't work due to #953034: [meta] Themes improperly check renderable arrays when determining visibility. Whatever solution is implemented should reference this issue so it can be updated later on.Comment #3
idebr CreditAttribution: idebr commentedPossibly this can also be fixed by #2289917: Convert "messages" page element into blocks
Comment #4
dmitrii CreditAttribution: dmitrii commentedThank for clarifications.
The issue blocked by #953034 or/and #2289917
Comment #5
Jeff Burnz CreditAttribution: Jeff Burnz commentedIn #2289917: Convert "messages" page element into blocks there is a check has_messages
$variables['has_messages'] = !empty($variables['message_list']);
, and in any case when that patch lands we will remove messages variable from Bartik and it becomes page.messages + block, likely in #2005546: Use branding block in place of page template branding variables (site name, slogan, site logo) or a new issue, this issue will then close, so I really don't think we should loose sleep on this issue and postpone it.Comment #6
emma.mariaThanks for the information @idebr and @Jeff Burnz! I tried searching for an issue and couldn't find it myself. Postponing so I don't forget this exists and hopefully the other issues are fixed soon.
Comment #7
joelpittetIf this problem persists feel free to re-open.