Problem/Motivation
While generating variable values for theme block processing, template_preprocess_block can delete the value of the block label before the block template can decide what to do with it. It does this based on the value of the 'label_display' flag in the block's configuration. If the flag is off it passes an empty string to the template. Although this might make sense if the only choice for the label is to print or not print the value, it denies the themer the opportunity to print but visually hide the label. The accessibility issue is now being addressed by #2614950: Add option for visually-hidden block titles. But it still means the value is being deleted by the system without giving the themer the option to do something with it. Drupal shouldn't be throwing away user data without telling them.
Proposed resolution
Do not delete the value of configuration.label in template_preprocess_block and pass it thru the 'label' variable and force the template to use configuration.label_display to decide whether to omit, visually hide, or make visible the string.
Remaining tasks
Modify template_preprocess_block to pass the value on intact.
Modify existing core block templates to make the appropriate decisions abut this value.
As far as I can see, existing documentation will not have to be changed.
Since #2614950: Add option for visually-hidden block titles is very active right now I am going to postpone this until that is completed, rather than tripping over each other.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | interdiff-2715687-5-7.txt | 551 bytes | dcrocks |
| #7 | 2715687-7.patch | 4.37 KB | dcrocks |
| #5 | 2715687-5.patch | 3.83 KB | dcrocks |
Comments
Comment #2
dcrocks commentedComment #3
dcrocks commentedThe current design impacts the use of a dynamic label for the block as well as the static label from the block configuration.
Comment #4
dcrocks commentedHow does "BlockStorageUnitTest.php" succeed when it is clear the 2 arrays being compared are not identical?
Comment #5
dcrocks commentedHere is a first attempt at a patch.
Comment #7
dcrocks commentedOne test assumes label can be empty.
Comment #8
dcrocks commentedPerhaps the issue title is misleading. template_preprocess_block shouldn't be making the decision about this flag before the themer can.
Comment #9
andrewmacpherson commentedComment #10
dcrocks commentedSpelling?
Comment #11
andrewmacpherson commentedComment #12
dcrocks commentedtemplate_preprocess_block reduces the usability of the 'display_label' flag and removes data that a themer might need. So this is a bug, not a task.
Comment #15
dcrocks commentedComment #16
mgifford@dcrocks - what is this postponed on?
Comment #17
dcrocks commentedOn #2614950: Add option for visually-hidden block titles. I mentioned it in the summary. That is active right now and both touch 'function template_preprocess_block'.
Comment #18
mgiffordAhh.. Ok, thanks.
Comment #31
smustgrave commentedThank you for reporting this problem. We rely on issue reports like this one to resolve bugs and improve Drupal core.
Since there has been no activity here for over 8 years we are asking if this problem persists on a currently supported version of Drupal. To help, add a comment explaining if the problem still occurs or not. Any extra detail you can provide can help others who experienced this.
Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.
Thanks!
Comment #33
smustgrave commentedWanted to bump this one more time.