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; ?>>

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

andypost’s picture

Status: Active » Needs review
Issue tags: +Needs backport to D7
FileSize
2.26 KB

This patch fixes this and provides test, Suppose we need to backport to D7 if possible

Everett Zufelt’s picture

Everett Zufelt’s picture

I'm not sure that the test is necessary, but the patch looks good to me. Let's get more feedback before RTBC.

Everett Zufelt’s picture

Component: block.module » markup

Changing component to get it in fornt of the markup team, as this is a markup change.

mgifford’s picture

The patch applies nicely. I confirmed that

is still showing up in the blocks.

This looks like a good one to get into core.

Everett Zufelt’s picture

Status: Needs review » Needs work

+ // 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.

rupl’s picture

Status: Needs work » Needs review
FileSize
4.19 KB

Patch incorporates Everett's feedback.

Everett Zufelt’s picture

Status: Needs review » Needs work

@rupl

Looks like you uploaded the patch from #4, or at least the strings are all the same :)

rupl’s picture

@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.

Everett Zufelt’s picture

Status: Needs work » Reviewed & tested by the community

RTBC 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.

Dries’s picture

Version: 8.x-dev » 7.x-dev

Committed to 8.x. Moving to 7.x for webchick to consider. This is a bugfix but it may break existing templates.

webchick’s picture

Version: 7.x-dev » 8.x-dev
Status: Reviewed & tested by the community » Fixed
Issue tags: -Needs backport to D7

Yeah, I don't think we can break templates (esp. block.tpl.php which is used everywhere) in stable releases. Sorry. :(

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

hass’s picture

Version: 8.x-dev » 7.x-dev
Status: Closed (fixed) » Reviewed & tested by the community

I 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.

hass’s picture

Is there any reference to $content_attributes_array in comments? It's also broken...

hass’s picture

Node also broken

xjm’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: +Needs backport to D7

Looking 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.

mgifford’s picture

attempted re-roll.

Status: Needs review » Needs work

The last submitted patch, 18: 1286532-block-content-attributes-18.patch, failed testing.

joelpittet’s picture

Status: Needs work » Needs review
FileSize
1.97 KB

Re-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.

mgifford’s picture

Thanks 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.....

  • Dries committed 26aa196 on 8.3.x
    - Patch #1286532 by andypost, rupl: () does not work for block default...

  • Dries committed 26aa196 on 8.3.x
    - Patch #1286532 by andypost, rupl: () does not work for block default...

  • Dries committed 26aa196 on 8.4.x
    - Patch #1286532 by andypost, rupl: () does not work for block default...

  • Dries committed 26aa196 on 8.4.x
    - Patch #1286532 by andypost, rupl: () does not work for block default...

  • Dries committed 26aa196 on 9.1.x
    - Patch #1286532 by andypost, rupl: () does not work for block default...