1

I need to add custom css classes to several blocks (can be blocks from view, or facet api, etc). Is there a way to do it without creating a template for every block? It could be useful a theme function, or a hook, that should do something like:

 if ($var == 'block_name') {
   $class_custom = 'my-custom-class';
 }

Is it possible?

2

There's a template function for this: template_preprocess_block.

Use $variables['classes_array'] to add classes to the block.

3

You can also use the Block class project for the matter.

Block Class allows users to add classes to any block through the block's configuration interface. By adding a very short snippet of PHP to a theme's block.tpl.php file, classes can be added to the parent element of a block. Hooray for more powerful block theming!

  • 1
    I know that module, the problem is that has not support for features or generally a way to export configuration. – arrubiu May 21 '13 at 7:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.