Quick follow up with latest updates (d995a7f):
I didn't have time (unfortunately) to update the project description page for 7.x-2.x, but we need to spend a little bit of time on this if we really want deployment of the new branch to be complete.

Any questions, feedback, comments, replies, reactions, suggestions, recommentations, advice, objections, concerns would be highly welcome.

Thanks again to all in advance.
Cheers!

Comments

kclarkson’s picture

Do we have to add the snippet for the 7.x-2.x versions ?

DYdave’s picture

Hi kclarkson,

Thanks a lot for your follow up on this.
This is exactly what this ticket should be about.

I haven't tried that myself yet, but would greatly appreciate if you could give some feedback on this:

In the 7.x-2.x version, the block class is stored in the css_class block property and should be accessible through:
$block->css_class

so if the snippet for the 7.x-1.x branch from the project's page:

<div id="block-<?php print $block->module .'-'. $block->delta; ?>" class="clear-block block block-<?php print $block->module ?> <?php print block_class($block); ?>">

Should be adapted, then it would be as follows:

<div id="block-<?php print $block->module .'-'. $block->delta; ?>" class="clear-block block block-<?php print $block->module ?> <?php print $block->css_class; ?>">

By default the block class is added to the block theme classes array, so you wouldn't need to modify anything in the template files.
However, if you wanted to further manipulate the class to display in specific markup in the template files, then the class should be called with $block->css_class.
 
I would greatly appreciate your feedback on this, since I didn't have time to test/try it myself.
Could you please let us know if it doesn't work? I would surely try taking a closer look at this.
 
Feel free to let us know if you would have any further questions, comments, ideas, suggestions, concerns or objections on any aspects of the theming with Block Class, I would be glad to provide more information or explain in further details.
 
Any feedback, testing, reporting, reviews or issues would be highly appreciated.
Thanks very much to all in advance.

kclarkson’s picture

Well from what i can tell you do not need to add any snippet as the class is printed after you name it in the blocks setting.

bcreeves’s picture

It is printed along with all the other classes. But what if you just want the custom class or want to manipulate the class name in some way?

bcreeves’s picture

When I use: print $block->css_class; it prints the class properly but I also get this error 8 times:

Notice: Undefined property: stdClass::$block_class in include()
DYdave’s picture

@bcreeves:
Thanks very much for your feedback on that.

Notice: Undefined property: stdClass::$block_class in include()

Are you still having this issue or is anyone else having the same problem?

Because I tried to test with a standard Drupal install and a block.tpl.php file with the Bartik theme, and wasn't able to reproduce this issue.

If you are still having this problem, could you please try providing a little bit more information?

  • Would you have changed anything to the template files? tpl.php files, template.php, etc....
  • Could you please provide more detailed information on all versions? (Block Class, Theme and Drupal Core version as well)
  • Could you please make sure you run the update script if you updated from 1.x?

Ideally, a screenshot could help as well.

On top of that, it would really help if you could also paste here (with some formatting) the debug backtrace from Commerce Devel (just need to install/enable the module and the backtrace can easily be copied from the Recent log messages detail view of the error log message).
Based on that we could perhaps give you further guidance on how to place more traces in the code and what could be causing this issue.

I would certainly be glad to look further into this issue, but currently, I am unable to reproduce the problem.

We would greatly appreciate if you could provide more detailed information on this issue.
Thanks very much in advance.

harley.orion’s picture

On 7.x-2.0 version, we found that the classes were not printing by default, but that adding:
print $block->css_class;
To the block tpl resolved the issue with no errors.
Is there any downside to using this snippet and adding this to the installation instructions? That would make installation of 7.x-2.x match the way the earlier versions are installed which is probably more intuitive anyway.

DYdave’s picture

Status: Active » Fixed

Hi guys,

Thanks very much once again for all your follow-ups, comments and replies on this issue.

Classes should actually be printed by default, if the theme used prints out the $classes template variable, as it is the case for the default Core Block template file, see block.tpl.php line 47 (whether it's a page, block, node, etc...):
<div id="<?php print $block_html_id; ?>" class="<?php print $classes; ?>"<?php print $attributes; ?>>

In short, the 7.x-1.x and 7.x-2.x versions of Block Class, add classes to the classes_array Block template variable, which is then tranformed into the string $classes template variable by the function template_process:
<?php $variables['classes'] = implode(' ', $variables['classes_array']); ?>

In other words, if the classes are not displayed by default (whatever the 7.x version of the module is), it either means they are overridden by the theme (for example, unset or overridden [THEME_NAME]_process in template.php file), or because the $classes variable is not printed in corresponding Block template file (for example block.tpl.php).

In this case, if the theme used is not leveraging the default/standard $classes template variables, Block CSS classes would have to be added manually, as you clearly explained, by accessing in the template file (for example, block.tpl.php) the Block object as follows: $block->css_class, which is perhaps a bit more intuitive than it was in previous versions.
 

Based on previous comments and feedbacks, I went ahead and modified Project's page to add the correct code snippet for the 7.x-2.x version, under the section How to add the PHP snippet (7.x-2.x, 7.x-1.x, 6.x-1.3 or lower).
Feel free to check the changes by comparing the with previous revision at diff-block_class-2434102-2647794.

Additionally, while updating the page, I took the opportunity to add a quick screenshot of the CSS Class(es) field added on Block's configuration page and restore Module's categories (mistakenly removed in a previous update).

I assume we would probably have to keep updating Project's page in the future as more changes are made to the module, but for now, these changes would seem to already cover the work initially planned in the issue summary.

Therefore, I allowed myself to mark this issue as fixed for now, but feel free to re-open it, or post a new ticket, at any time if you have any further objections, comments or questions with this issue or related changes to Project's page (diff-block_class-2434102-2647794 - we would surely be happy to hear your feedback).

Please let me know if you would have any further comments, feedback, questions, issues, objections, suggestions or concerns on the latest changes to the Project's page or this ticket in general, I would be glad to provide more information or explain in more details.

Thanks again to everyone for your testing, reviews, feedback and comments on this issue.
Cheers!

Status: Fixed » Closed (fixed)

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