I am trying at add the following code within the adaptivetheme_preprocess_block(&$vars) in the atcore preprocessblock.inc for use with a sub theme

{/* Set shortcut variables */
  $block_id = $vars['block']->module . '-' . $vars['block']->delta;
  $classes = &$vars['attributes_array']['class'];

  /* Add classes based on the block delta */
  switch ($block_id) {
    /* Add .badge class to block #14 */
    case 'block-14':
      $classes[] = 'badge';
      break;
    /* Add .form class to block #20 */
    case 'block-20':
      $classes[] = 'form';
      break;
  }
}

I want a way to add a class to blocks I create so I can theme against this class rather than block I'd which may change when I apply the theme to other sites. Just looking door guidance as to the simplest way of doing this please

Comments

artatac’s picture

Title: add class to locks » add class to blocks

...blocks

Jeff Burnz’s picture

The code is illogical in terms of the issue, you switch on ID, isn't that what you are trying to avoid?

Also why hack the core theme, just use preprocess in your subtheme.

artatac’s picture

Good point I will add it to the sub theme.
The reason for I'd is that as far as I am aware all I know about the block I want the style, that is unique, is block-block-12 and I wanted to add a class say block-teammembers and style that. I came across the above code and hoped hat would do it for me.

ydahi’s picture

there's a module for that: http://drupal.org/project/block_class