You are here

function block_class in Block Class 7

Same name and namespace in other branches
  1. 5 block_class.module \block_class()
  2. 6.2 block_class.module \block_class()
  3. 6 block_class.module \block_class()

Return classes as string.

Statically cache the block classes values for all the blocks to avoid firing multiple queries if there are many blocks.

3 calls to block_class()
block_class_form_alter in ./block_class.module
Implements hook_form_alter().
block_class_preprocess_block in ./block_class.module
Implements theme_preprocess_block().
block_class_preprocess_panels_pane in ./block_class.module
Implements hook_preprocess_HOOK().
7 string references to 'block_class'
BlockClassTestCase::setUp in ./block_class.test
Enable modules and create user with specific permissions.
block_class_features_api in ./block_class.module
Implements hook_features_api().
block_class_features_export in ./block_class.features.inc
Implements hook_features_export().
block_class_features_export_options in ./block_class.features.inc
Implements hook_features_export_options().
block_class_features_export_render in ./block_class.features.inc
Implements hook_features_export_render().

... See full list

File

./block_class.module, line 63
Enhanced control over the CSS Classes of any Block.

Code

function block_class($block) {
  $cache =& drupal_static(__FUNCTION__);
  if (count($cache) <= 0) {
    $query = db_select('block_class');
    $query
      ->addField(NULL, 'css_class');
    $query
      ->addExpression("CONCAT(module, '_', delta)", 'block_key');
    $cache = $query
      ->execute()
      ->fetchAllKeyed(1, 0);
  }
  return !empty($cache[$block->module . '_' . $block->delta]) ? check_plain($cache[$block->module . '_' . $block->delta]) : '';
}