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.
This coming from #1285364-14: Remove search-block-form template for form rendering consistency
Implementing hook_preprocess_block() has no ability to change $variables['title_attributes_array']['class']
because block.tpl.php has hardcoded class attribute
<div class="content"<?php print $content_attributes; ?>>
Comment | File | Size | Author |
---|---|---|---|
#20 | fix-1286532-20.patch | 1.97 KB | joelpittet |
#18 | 1286532-block-content-attributes-18.patch | 2.66 KB | mgifford |
#7 | 1286532-block-content-attributes-7.patch | 4.19 KB | rupl |
#1 | 1286532-block-class.patch | 2.26 KB | andypost |
Comments
Comment #1
andypostThis patch fixes this and provides test, Suppose we need to backport to D7 if possible
Comment #2
Everett Zufelt CreditAttribution: Everett Zufelt commentedSee #1286530: Meta: Templates hard code class attribute, and shouldn't
Comment #3
Everett Zufelt CreditAttribution: Everett Zufelt commentedI'm not sure that the test is necessary, but the patch looks good to me. Let's get more feedback before RTBC.
Comment #4
Everett Zufelt CreditAttribution: Everett Zufelt commentedChanging component to get it in fornt of the markup team, as this is a markup change.
Comment #5
mgiffordThe patch applies nicely. I confirmed that
This looks like a good one to get into core.
Comment #6
Everett Zufelt CreditAttribution: Everett Zufelt commented+ // Test default classes.
// Test adding a class to the block content.
+ $variables2['content_attributes_array']['class'][] = 'test-class';
template_preprocess_block($variables2);
$this->assertEqual($variables2['theme_hook_suggestions'], array('block__footer', 'block__block', 'block__block__hyphen_test'), t('Hyphens (-) in block
delta were replaced by underscore (_)'));
+ // Test default class been added.
// Test that the default class and added class are available.
+ $this->assertEqual($variables2['content_attributes_array']['class'], array('test-class', 'content'), t('Default classes for block content works'));
t('Default .content class added to block content_attributes_array')
I'm still not sure that the test is necessary, but with these string changes I think we can set to RTBC.
Comment #7
ruplPatch incorporates Everett's feedback.
Comment #8
Everett Zufelt CreditAttribution: Everett Zufelt commented@rupl
Looks like you uploaded the patch from #4, or at least the strings are all the same :)
Comment #9
rupl@Everett, I used
git format-patch
to generate the file in #7, which chunks the patch into individual commits that retain authorship. So you're correct, #7 does include the exact patch from #1, with an additional diff succeeding it.I got into this habit after finding the advanced patch contributor guide. This method of feature-branching, rebasing, and generating a verbose patch has helped me be more aware of others' contributions to issues, not to mention the inner workings of git itself.
Comment #10
Everett Zufelt CreditAttribution: Everett Zufelt commentedRTBC on patch in #7.
This patch removes the hard coded class attribute on the content div in block.tpl.php, and adds it in template_preprocess_block().
It also adds a test to make sure that the .content class, and any additional classes added in hook_preprocess_block using $variables['content_attributes_array'] are available to the template.
Without this patch adding a class using $variables['content_attributes_array']['class'][] = 'foo'; will cause two class attributes to be rendered for the content div in block.tpl.php.
Comment #11
Dries CreditAttribution: Dries commentedCommitted to 8.x. Moving to 7.x for webchick to consider. This is a bugfix but it may break existing templates.
Comment #12
webchickYeah, I don't think we can break templates (esp. block.tpl.php which is used everywhere) in stable releases. Sorry. :(
Comment #14
hass CreditAttribution: hass commentedI need a FIX for D7 as I cannot theme the blocks as required. How should this break a theme? I have no idea. Please commit to D7, too.
Comment #15
hass CreditAttribution: hass commentedIs there any reference to $content_attributes_array in comments? It's also broken...
Comment #16
hass CreditAttribution: hass commentedNode also broken
Comment #17
xjmLooking closely at the change, I can see that the output markup should be the same. So maybe it's backportable? Let's set this to NR and try to get some more feedback.
Comment #18
mgiffordattempted re-roll.
Comment #20
joelpittetRe-rolled. @mgifford I think it's just missing the class being added and some extra default settings stuff got added.
I'm fairly positive this change will not negatively effect themes. The content class is still added just moved to preprocess. This fixes a possible bug where you'd get two class attributes if you passed that in through a module.
So I fail to see where this could cause an issue. (naive I know)
Though this can be patched/fixed in a base theme, it likely shouldn't be.
Comment #21
mgiffordThanks for removing the default.settings.php changes that snuck in.
I installed this patch quickly with zen, adaptivetheme, mothership, fusion_core, omega, framework, & marinelli.
Didn't see anything obviously wrong. Wish we had a mailinglist of Drupal theme maintainers we could send a quick note out and have them verify that it was all good.....