Posted By

Onfire60 on 01/19/11


Tagged

drupal id block Blocks 6


Versions (?)

Drupal 6 - Better Block Ids Function


 / Published in: PHP
 

Copy the first code snippet to your theme's template.php.

Then call the following section in you block template file.

  1. /*The function*/
  2. <?php
  3. function block_id(&$block) {
  4. $info = module_invoke($block->module, 'block', 'list');
  5. if ($info[$block->delta]['info']) {
  6. $block_id = 'block-' . $block->module . '-' . $info[$block->delta]['info'];
  7. $block_id = str_replace(array(' ', '_'), '-', strtolower($block_id));
  8. return preg_replace('/[^\-a-z0-9]/', '', $block_id);
  9. } else {
  10. return 'block-' . $block->module . '-' . $block->delta;
  11. }
  12. }
  13. ?>
  14.  
  15. /*Call this in your block.tpl.php file*/
  16. <?php print block_id($block); ?>

Report this snippet  

You need to login to post a comment.