I have no idea why all my blocks disapear as soon as i enable my custom module. (which i have used before)
Any help much appreciated.

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

	if($op == 'list') {

		$block[0]["info"] = t('test Navigation');
		// BLOCK_CACHE_PER_ROLE will be assumed for block 0.
	
		return $block;
		
	} else if ($op == 'view') {
		
		$block = array('subject' => t('testNavigation'), 'content' => test_display_block());
		
		return $block;
	}
} 

Comments

antkiewicz’s picture

First,
The 'list' op should return array called $blocks not $block (hook_block()) ex:

....
if($op == 'list') {

$blocks[0]["info"] = t('test Navigation');

return $blocks;

} else if ....

Two, I think you should check the return of test_display_block() function. For testing you could just replace it with a string like:

.... 'content' => '<p>Hello World!</p>'

If the above snippet works, then you know it is that return of test_display_block() function is the culprit.

nevets’s picture

Is the function test_display_block() defined somewhere?

hypeweb’s picture

Ok sorry about the block -> blocks thing, should of known.
However my problem still persists. I have taken code from drupal api as is, and pasted it into the module and deleted
my functions. The problem still persists, after re saving modules, and clearing cache.

/**
 * Implementation of hook_block().
*/
function fruitrun_block($op = 'list', $delta = 0, $edit = array()) {

	switch($op){
		case 'list':
		$blocks[0]['info'] = t('pending comments');
		$blocks[0]['cache'] = BLOCK_NO_CACHE;
		return $blocks;
	}
} 

So it appears just having the actual hook_block, makes all other blocks disapear.

hypeweb’s picture

Problem solved, by changing the module name. This is not realy a solution as I would of liked to know what caused this.
I even tried clearing any refernces to the module and block in the database, but that dident work. Good for now.

Kevin Hankens’s picture

Hey there! Is it possible that your module had the same name as your active theme?

I just ran into a similar problem and I believe that was the case.

thtas’s picture

YES! thankyou! i spent ages trying to figure out what was wrong with my blocks.

edjay’s picture

A lot ;)

chromix’s picture

Thank you for saving me about several days worth of frustration and gnashing of teeth.

sgdavis’s picture

DAMMIT!! Was this ever reported as a bug??

I just spend an entire day on this issue (well not really, but all of my time allocated to this project today at least)...

EDIT: Just fixed my problem with a rename of my theme. GRRRR