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
Fields label in views can be configured to display or hide the colon after the label.
Hiding the colon does not work when the field is used as grouping field: the group label will always display the colon regardless of the selected option.
Comment | File | Size | Author |
---|---|---|---|
#12 | view-after-no-colon.png | 7.85 KB | danflanagan8 |
#12 | view-after-colon.png | 7.97 KB | danflanagan8 |
#12 | view-before-no-colon.png | 7.75 KB | danflanagan8 |
#12 | view-before-colon.png | 7.61 KB | danflanagan8 |
#10 | 3247619-10.patch | 3.37 KB | Lendude |
Comments
Comment #2
larowlanThanks for reporting
Comment #3
beatrizrodriguesComment #4
beatrizrodrigues@FiNeX Could you provide me more information about the problem? I created a scenario but I'm not being able to understand when this happens, this was what I did:
I'm not sure if I follow the right steps...'Cause as I said I couldn't reproduce the problem you talked about. So if you could give me the steps it would help me a lot. thank you!!
Comment #5
FiNeX CreditAttribution: FiNeX as a volunteer commentedHi,
the steps to reproduce the bug on a clean D9 installation are:
0) create at least one article
1) create a view with article nodes. Page or block it's the same.
2) select to display fields: title and something which can be grouped, like author.
3) on the "author" field settings select a custom label and be sure that the ":" option is turned off. Also disable to print the author as link to keep the output clean.
4) select unformatted list (or html list, it does not matter)
5) select the "author" field as a grouping field.
6) save the view and watch the result:
The ":" is hidden from the rendered field, but on the grouping field title is still visible.
Thanks for your attention.
Comment #6
beatrizrodriguesThank you for the steps, @FiNeX. I was able to reproduce so I'll be working working on this.
Comment #7
FiNeX CreditAttribution: FiNeX as a volunteer commentedThank you very much @beatrizrodrigues !
Comment #8
beatrizrodriguesI unassigned me from the issue because I'm not being able to resolve it. I found the point of the code that I could remove the colon
(
template_preprocess_views_view_unformatted(&variables)
), and it stayed just it had to be, but I'm having some problems with find the property that tells me that the label colon it is not requested. Besides, I think the changes must be not only thetemplate_preprocess_views_view_unformatted
but at all formats that includes the "place a colon" option. So, as I'm very stuck, I will unassigned me. Thanks.Comment #10
LendudeThis is handled in the StylePluginBase class and it does indeed not take this setting into consideration.
Here is a test and a fix for this.
Comment #12
danflanagan8I made a little view to test and it looks like the patch works.
And the new test coverage looks good. It fails perfectly.
I thought that the changes below were out of scope, just some nearby cosmetic changes. Then I realized that we need to keep
$expected
from being altered because we use it in the new coverage further down.But now this all makes sense. RTBC. Cheers!
Comment #13
FiNeX CreditAttribution: FiNeX as a volunteer commentedHi, thank you both for the fix!
Comment #15
catchLooked at the test to see if it was worth trying to redefine $expected into multiple arrays in the first place, but that'd be tonnes of boilerplate so the bits of manipulation seems OK.
Committed/pushed to 10.0.x and cherry-picked to 9.4.x and 9.3.x, thanks!