I have developed custom module in drupal 6.9 and implemented two hooks hook_block and hook_form_alter. Form alter hook is working fine but there is a problem with block hook. This block hook works fine before the admin module page open. But whenever i visit admin/build/modules page then no block appears in the site all blocks of all modules which are enabled are disapears. and when i comments this block hook and refresh site then blocks of others modules which are enabled are appears again. Even i have tried with and without BLOCK_ALWAYS_CACHED but no success.

Anyone has idea what is problem with my block hook? here is the code


function testmodule_block($op = 'list', $delta = 0){
  global $base_url;
    if($op == 'list'){
      $blocks[0] = array('info'=>t('Our Mission'));
      $blocks[1] = array('info'=>t('Quarterly Newsletters'));
      return $blocks;
    }elseif($op == 'view'){
      switch($delta){
        case 0:
          $output = "<div class='block-mission'><img src='".$base_url."/images/mayisha_akbar.jpg' alt='Mayisha Akbar' />";
          $output .= l("<input type='button' value='".t('Our Mission')."'>",'node/4',array('html'=>true));
          $output .= "</div>";
          $block = array('subject' => '','content' => $output,'cache_mode'=>BLOCK_ALWAYS_CACHED);
        return $block;
        case 1:
          $output = "<div class='block-mission'>
                        <div>
                            <img src='".$base_url."/images/jrposse_sign.jpg' alt='Mayisha Akbar' />
                        </div><div>";
          $output .= l("<input type='button' value='".t('Quarterly News Letters')."'>",'',array('html'=>true));
          $output .= "</div></div>";
          $block = array('subject' => '','content' => $output,'cache_mode'=>BLOCK_ALWAYS_CACHED);
        return $block;
      }
    }
}

Comments

jeanpierre’s picture

Hello !

I have the same problem, it is very wired...

Here is the very simple code I use :

function mymodule_block($op='list', $delta=0) {
  if ($op == 'list') {
    $block[0]['info'] = t('Test 1');
    $block[1]['info'] = t('Test 2');
    return $block;
  }
  else if ($op == 'view') {
    if ($delta == 0) {
		return;
    }
    else if ($delta == 1) {
		return;
    }
  }
}

If any one has got an idea, it would be very usefull !

Thanks in advance.

--
Jean-Pierre

jeanpierre’s picture

Yep !

You have to rename your theme's name : it has to be different than the name of your module otherwise it makes all blocks disapears !

Source : #118083: Block Hook Causes blocks to disappear

;)

--
Jean-Pierre

khoomy’s picture

I have same name of module and theme. After changing the name of my module it is working. Many thanks for your solution.

Khurram Fraz