Created
November 19, 2012 21:41
-
-
Save chrisl8888/4114195 to your computer and use it in GitHub Desktop.
drupal 7: adding classes to blocks with preprocessing. borrowed from http://www.webbykat.com/2012/09/adding-class-block-drupal-7-block-class-module-vs-preprocessing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Selectively add classes to certain blocks | |
| * | |
| * Implements alpha_preprocess_block | |
| */ | |
| function sil_alpha_preprocess_block(&$var) { | |
| $block_id = $var['block']->module . '-' . $var['block']->delta; | |
| $classes = &$var['attributes_array']['class']; | |
| 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; | |
| default: | |
| // Print out block id's | |
| // var_dump($block_id); | |
| break; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment