Created
May 9, 2012 00:58
-
-
Save zachharkey/2640840 to your computer and use it in GitHub Desktop.
Add block_class classes to panel pane markup
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 | |
/** | |
* Modify panels pane template variables | |
*/ | |
function MYTHEME_preprocess_panels_pane(&$variables) { | |
// Merge block_class classes into the pane's $classes_array | |
if (module_exists('block_class')) { | |
// Insert additional classes into panels panes. | |
if ($variables['pane']->type == 'block') { | |
// Infer the block's $module and $delta from the pane subtype. | |
$block_parts = explode('-', $variables['pane']->subtype); | |
// Load the block based on the block parts. | |
$block = block_load($block_parts[0], $block_parts[1]); | |
// Return block_class classes as string. | |
$css_class = block_class($block); | |
// Add a generic module type block class. | |
$variables['classes_array'][] = drupal_html_class('pane-' . $block->module); | |
// Add $css_class to the $classes_array. | |
$variables['classes_array'][] = $css_class; | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I found that this fails if the delta of the module contains a "-", like in blocks generated by Views.
I fixed it replacing line 13 with the following: