Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I create multiple different blocks in one module in Drupal 6?

I'm using hook_block to create a block with the name of the custom module I'm creating.
I'm not being able to create a block without using myModuleName_block.

Do I need to do different modules for every different block I want to create?

like image 525
ino Avatar asked May 20 '10 10:05

ino


1 Answers

You can make several blocks with hook_block, just use the $delta.

function hook_block($op = 'list', $delta = 0, $edit = array()) {
  switch ($op) {

    case 'list':
      $blocks[0]['info'] = t('Block 1');
      $blocks[1]['info'] = t('Block 2');
      return $blocks;

    case 'configure':
      if ($delta == 0) {
        // Block 1
      }
      else if ($delta == 1) {
        // Block 1
      }

 ....

}
like image 91
googletorp Avatar answered Sep 22 '22 19:09

googletorp