Hello.
I have a problem with a small module for a client. This module consists only of one block to show some info about the stock.
It took me several hours to get the block just to show up in the block-list (/admin/build/block) on my development server. But when I got it to be shown it was easy from there. I don't know how or why but it suddenly worked. And now it seems the problem is reapeting itself on the production server.
I tried several combinations of enabling and disabling the module, clearing the caches.
This is the code I have right now:
/*
* Implementaion of hook_block
*/
function company_stock_info_block( $op='list', $delta=0 ) {
if ($op=='list') {
$blocks[0]['info'] = t('Company stock info');
$blocks[0]['cache'] = BLOCK_NO_CACHE;
$blocks[0]['status'] = TRUE;
$blocks[0]['visibility'] = TRUE;
return $blocks;
}
else if ($op=='view') {
$block['subject'] = t('company stock info');
$block['content'] = company_stock_info_fetch();
return $block;
}
}
When i try echo 'Test'; just before return $blocks; it prints out the word "Test", so the hook is run. I've tried several different combinations of items in the array (with "info" always on).
I have a few I ideas that might be the cause quirky behaviour:
* The module's name is to long ("company_stock_info" = 3 words). I haven't tried to change the name yet, but is sounds weird that i would have to change it.
* The module is located in sites/companysite.se/modules. We're using a multisite install and we don't want others to be able to use this module.
The function company_stock_info_fetch() fetches an XML-file and parses it. This module doesn't use any database, except the table "cache".
Can anyone see if I'm doing this wrong? Does hook_block have som quirks?
Thank you for reading!
//Andreas Rydberg
Comments
Tjenare! Check that you have
Tjenare!
Check that you have spelled the filenames exactly as the module name and don´t use Sweedish letters.
try this out