Since #422824: Add more specific body classes so page elements can be themed based on page type, we are using template suggestions to figure out body classes. Running theme_get_suggestions(array('node', '1'), 'page', '-') just as template_preprocess_html() does returns the following suggestions:
Array(
[0] => page-node
[1] => page-node-%
[2] => page-node-1
[3] => page-front
)
Now drupal_html_class() will turn page-node-% into 'page-node-', which is a meaningless class. Let's either strip the wildcard solutions before running drupal_html_class() or turn % into something meaningful.
Comment | File | Size | Author |
---|---|---|---|
#42 | 1242908-42.patch | 4.55 KB | smustgrave |
#42 | 1242908-42-tests-only.patch | 3.68 KB | smustgrave |
Comments
Comment #1
Dave ReidNothing to do with HTML5. Also, I'm not sure *why* we even support a suggestion like page__node__% to begin with? I think we should remove the wildcard functionality.
Comment #2
Dave ReidThis change seems to have originated with #167112: PHPTemplate Suggestion wildcard. We should remove them when processed by CSS classes.
Comment #3
Dave ReidLet's skip any suggestions with wildcards in them.
Comment #4
barraponto CreditAttribution: barraponto commentedWonderful.
I have added a comment to make it clear why we are filtering % out.
Comment #5
marcingy CreditAttribution: marcingy commentedSorry for the nitpick
// Ignore front page and wildcard suggestions
needs a period at the end otherwise looks good.
Comment #6
barraponto CreditAttribution: barraponto commentedDone.
@marcingy You will like the patch I posted at #1054848: Fixing common typos through codespell.py, although it needs updating.
Comment #7
barraponto CreditAttribution: barraponto commentedComment #8
Hanpersand CreditAttribution: Hanpersand commentedSubscribing.
Comment #9
marcingy CreditAttribution: marcingy commentedlooks good
Comment #10
andypost+1, this also fixes taxonomy page body classes
before patch:
html not-front logged-in no-sidebars page-taxonomy page-taxonomy-term page-taxonomy-term- page-taxonomy-term-45 toolbar toolbar-drawer footer-columns
after patch:
html not-front logged-in no-sidebars page-taxonomy page-taxonomy-term page-taxonomy-term-45 toolbar toolbar-drawer footer-columns
Comment #11
pvasili CreditAttribution: pvasili commentedSubscribing
Comment #12
Damien Tournoud CreditAttribution: Damien Tournoud commentedI was ready to write "This check needs to go into
theme_get_suggestions()
", until I saw comment #2.So either:
Comment #13
barraponto CreditAttribution: barraponto commentedThe reason we have the wildcard suggestion there, in the first place, is to have different templates for /user and /user/1. It makes sense for templates and it makes sense for CSS classes as well.
According to http://www.w3.org/TR/CSS2/syndata.html#characters, the closest we can get to a wildcard class would be ending it with a hyphen. I agree we should use a explicit string (-wildcard or -ALL). I wonder if it ever conflicts with the template name (let's hope not).
Comment #14
BarisW CreditAttribution: BarisW commentedReplaced % with 'wildcard' in list_themes().
Body classes before:
"html not-front logged-in one-sidebar sidebar-first page-node page-node- page-node-1 node-type-article toolbar toolbar-drawer"
Body classes after:
"html not-front logged-in one-sidebar sidebar-first page-node page-node-wildcard page-node-1 node-type-article toolbar toolbar-drawer"
Comment #16
barraponto CreditAttribution: barraponto commentedUpdating the tests.
Comment #17
BarisW CreditAttribution: BarisW commentedReroll.
Comment #18
alansaviolobo CreditAttribution: alansaviolobo commentedReroll.
Comment #19
BarisW CreditAttribution: BarisW commentedThe comments have been removed, so let's remove it for the wildcard too.
Comment #22
BarisW CreditAttribution: BarisW at LimoenGroen commentedHere's a re-roll.
Comment #23
mgiffordNeeds re-roll.
Comment #24
BarisW CreditAttribution: BarisW at LimoenGroen commentedComment #25
BarisW CreditAttribution: BarisW at LimoenGroen commentedComment #36
ranjith_kumar_k_u CreditAttribution: ranjith_kumar_k_u at Zyxware Technologies commentedRe-rolled for 9.2
Comment #41
smustgrave CreditAttribution: smustgrave at Mobomo commentedRemoved #36 and fixed testing issue.
Tried to interdiff but got
interdiff: Error applying patch1 to reconstructed file
Comment #42
smustgrave CreditAttribution: smustgrave at Mobomo commentedThis is the same as #41 but with a tests-only patch.
Comment #44
smustgrave CreditAttribution: smustgrave at Mobomo commentedComment #46
catchIsn't page__node identical to page__node__wildcard?
Comment #47
smustgrave CreditAttribution: smustgrave at Mobomo commentedGuess it’s the same so should we remove page_node_%
Should we be worried about BC