I updated block_class from 7.x-1.2 to the latest 7.x-2.3 and now the classes I have added to blocks in the UI are not added to the `$classes` array in any template that implements `block.tpl.php`.
I confirmed that the permission to allow Administrators was checked.
Hacking the module a little bit, I confirmed that every block falls in the "else" even when there are valid classes shown in the UI and on the core block table's css_class column.
/**
* Implements theme_preprocess_block().
*
* Extend block's classes with any user defined classes.
*/
function block_class_preprocess_block(&$vars) {
$block = $vars['block'];
if (!empty($block->css_class)) {
$classes_array = explode(' ', $block->css_class);
foreach ($classes_array as $class) {
$vars['classes_array'][] = drupal_clean_css_identifier($class, array());
}
}
else {
print "BLOCK CSS IS EMPTY"; //everything is falling into the else
}
}
Please see the attached screenshots to confirm if I have everything set up correctly. Updating the code and db from 7.x-1.2 to 7.x-2.3 was seamless with no errors.
Comment | File | Size | Author |
---|---|---|---|
#3 | block-region-classic.png | 8.07 KB | wesleymusgrove |
#3 | block-region-context.png | 12.54 KB | wesleymusgrove |
block-class-html.png | 32.72 KB | wesleymusgrove | |
block-class-permission.png | 10.3 KB | wesleymusgrove | |
block-class-ui.png | 34.48 KB | wesleymusgrove |
Comments
Comment #2
wesleymusgrove CreditAttribution: wesleymusgrove commentedComment #3
wesleymusgrove CreditAttribution: wesleymusgrove commentedIs this new css_class property on the block variable not compatible with the 7.x-3.6 Context module?
Because when I assign a block to a particular region using the classic Structure > Blocks method and force the "css_tester" block to show up in the sidebar_first region, the `$variables['block']` in `hook_preprocess_block` contains the correct custom css class, which gets correctly written out to the HTML. See attached image
However... when I assign the exact same block to the exact same region using Context, the css_class property does not get added to the `$variables['block']`. See attached image
I rely on Context to assign blocks to regions, so this is kind of a big deal to me. Can anyone reproduce this??
Comment #4
DYdave CreditAttribution: DYdave at DAVYIN Internet Solutions / 戴文信息科技有限公司 commentedHi @wesleymusgrove
Thank you very much for your interest in the Block Class module and for posting this Bug report.
Thanks a lot for your great efforts to document this issue with screenshots, data dumps, various test case scenarios, that's really amazing... I think it's the first time I get the chance to answer such a clear and well documented issue (if only we could get more of these and less of the ineffective one liners...).
Alright, straight to the problem:
So, just to clarify a little bit, since the issue summary got me a bit confused:
Based on #3, the problem you're having right now is actually:
"The configured CSS Block Classes don't display when Block is shown through Context" (in this case context-7.x-3.6)
If you don't use Context, after updating from block_class-7.x 1.3 to block_class-7.x 2.3, are you able to display Block CSS classes properly, just by assigning a simple Block to a region?
(I'm trying to isolate the issue)
Since it's not the first time we hear in this issue tracker about potential compatibility issues with the Context module, we made sure it would be tested in code with automated tests.
See test case
BlockClassContextTestCase
, in block_class.test, line 191.Following up with this reply, I queued a test on the dispatcher, and I'm not sure if you have access to that, but feel free to take a closer look at the results of block_class-7.x-2.x-dev test with PHP 5.3 & MySQL 5.5, Drupal 7.x:
Tested with:
In particular: context-7.x-3.7
Every test was passed successfully, so I guess I would be pretty confident to say block_class-7.x-2.3 should work fine with context-7.x-3.7.
Maybe you could also try running module's test case on your site, just in case.
Otherwise:
I hope this allows us to get a few initial elements narrowed down in order to step forward towards swifly resolving your problem.
Thanks in advance for your reply, testing/reporting, feedback and participation in this module's issue tracker.
Thanks again so much for the screenshots and data dumps.
Cheers!
Comment #5
wesleymusgrove CreditAttribution: wesleymusgrove commentedI have more testing to do on this issue, but upgrading to context-7.x-3.7 did not resolve it.
Other context related modules that I'm using are:
I am able to assign a simple Block to a region in Structure > Blocks and the css_class works. But it doesn't work when I assign the same block to the same region through Context.
Comment #6
DYdave CreditAttribution: DYdave at DAVYIN Internet Solutions / 戴文信息科技有限公司 commentedHi @wesleymusgrove,
Thanks again very much for your prompt reply.
Wow!!! You really stocked up on Context related modules :D
According to your tests so far and an issue with Context Respect, previously logged in this tracker (#2329563: Block Class doesn't work with Context Respect), I'd wager, without too much uncertainty that the problem comes from one of the Context related modules...
(see also #1940122: Block Class doesn't work with Context, for narrowing down to "Context related" modules)
I'd say, the modules implementing conditions for Context are less likely to be problematic. The ones implementing actions or displaying blocks are probably more likely to be causing the issue, therefore, I would recommend to start testing these modules first, such as:
(I would start testing and checking these modules first)
Although, to be perfectly honest, I have probably only really used/tested about 2 of all the modules you listed...
Once again, thank you very much for your feedback on this and we're hoping you will be able to narrow down the problem deep enough to find the culprit and perhaps come up with a patch for related module at some point.
If there's anything else we could to to help, please let us know.
Cheers!
Comment #7
wesleymusgrove CreditAttribution: wesleymusgrove commentedThis isn't a very satisfying fix, but I disabled all those Context related modules (except for Context and Context UI) at the **same time** (not helpful for debugging...I know), cleared all cache, and Block Class started working when assigned to a region via Context. Then I re-enabled all those modules one-by-one (clearing all caches in between) and could not get it to break! Block Class just kept working as expected. Then I disabled them one-by-one (clearing all caches in between) and re-enabled them one-by-one again and Block Class continued to work like a champ. I'm thinking this was just some weird caching issue with my local environment. Sorry to raise such a ruckus and thanks @DYdave for your attention to my issue!
Comment #8
wesleymusgrove CreditAttribution: wesleymusgrove commentedActually when I pushed these block class and context module updates to production I realized that the culprit was Context Block Cache Alter 7.x-1.x-dev. Disabling that module fixed the block class issues I was having, which makes sense because that module would have cached off the previous version of the block object before the css class was moved to the block table...or at least that's what I'm going to tell myself so I can get some sleep at night lol.
Comment #9
DYdave CreditAttribution: DYdave at DAVYIN Internet Solutions / 戴文信息科技有限公司 commentedHi @wesleymusgrove,
Thanks a lot for following up on this issue so promptly.
OMG!! I didn't even know this module existed! :D
Context Block Cache Alter seems pretty experimental... Why am I not suprised there were caching compatibility issues with Block Class :)
Relating to #2324341: Block classes removed and changing issue title.
If you would still be interested in squashing this issue for good, and had some time to spare, you could perhaps take a closer look at #2324341: Block classes removed and ideally come up with a patch.
Otherwise, I'm very happy you were able to fix the problem on your end and found a reasonable potential explanation for the issue.
Once again thank you very much for logging all the results of your numerous tests in this issue (exceptional!), which will allow us to keep narrowing down, with more ease, Context related compatibility support requests in the future.
For now, @wesleymusgrove, I allowed myself to mark this issue as Fixed, but feel free to re-open it, or post a new ticket, at any time if you have any further objections with the solution suggested in this ticket or the related one (we would surely be happy to hear your feedback).
Feel free to let us know if you would have any further comments, questions, issues, suggestions, objections or ideas on this ticket in general, we would certainly be glad to provide more information.
Many thanks in advance to everyone for your reviews, testing, reporting and participation in this module's issue tracker.
Cheers!
Comment #11
BerdirIf somoene is debugging missing classes after updating modules, see #2645612: Attributes array doesn't populate classes.