Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By hypeweb on
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
List op returns $blocks
First,
The 'list' op should return array called $blocks not $block (hook_block()) ex:
Two, I think you should check the return of test_display_block() function. For testing you could just replace it with a string like:
If the above snippet works, then you know it is that return of test_display_block() function is the culprit.
Is the function
Is the function test_display_block() defined somewhere?
Problem still persists
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.
So it appears just having the actual hook_block, makes all other blocks disapear.
Problem solved, by changing
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.
Module name?
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.
YES! thankyou! i spent ages
YES! thankyou! i spent ages trying to figure out what was wrong with my blocks.
THX !
A lot ;)
Thank you
Thank you for saving me about several days worth of frustration and gnashing of teeth.
This ever get reported?
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