Skip to content

Instantly share code, notes, and snippets.

@opi
Forked from GoZOo/gist:4268937
Created December 12, 2012 15:57
Show Gist options
  • Save opi/4268945 to your computer and use it in GitHub Desktop.
Save opi/4268945 to your computer and use it in GitHub Desktop.
Drupal: Add class and attributes from custom blocks
/*
* Add class and attributes from custom blocks
*/
function phptemplate_preprocess_block(&$vars) {
if(isset($vars['block']->attributes)) {
if(isset($vars['block']->attributes['class'])) {
$vars['classes_array'] = array_merge($vars['classes_array'], $vars['block']->attributes['class']);
unset($vars['block']->attributes['class']);
}
if(!empty($vars['block']->attributes)) {
$vars['attributes_array'] = array_merge($vars['attributes_array'], $vars['block']->attributes);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment