/ Published in: PHP
This code goes directly into your template.php file after you remove the open and close PHP tags at the beginning and end.
Then place the call below in your block.tpl.php. Don't forget to flush cache.
Then place the call below in your block.tpl.php. Don't forget to flush cache.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php /** * Hook Preproccess Block */ function phptemplate_preprocess_block(&$vars) { $block = $vars['block']; // don't do anything if this block is not from views module or if delta < 32 chararacters // because md5 is always 32 if ($block->module == 'views' && $chars_delta >= '32') { //get from variable table the hashes and their corresponding views name, in an associative array $hashes = variable_get('views_block_hashes', ''); // add a nice new template suggestion if this delta is a hash $block->custom_classes['block_id'] = $block->module .'-'. $hashes[$block->delta]; $vars['template_files'][] = $block->custom_classes['block_id']; } } else { // just set the normal block id for css $block->custom_classes['block_id'] = $block->module .'-'. $block->delta; } } ?> /*How to call this in block.tpl.php*/ <div id="block-<?php print $block->custom_classes['block_id']; ?>" class="clear-block block block-<?php print $block->module ?>">