I created a module with a block hook. As soon as I do so, all block disappear.

function module_block($op = 'list', $delta = 0, $edit = array()) {
/** ...nothing here... */
}

patch file attached is infact a zip of the module.

CommentFileSizeAuthor
module-test.patch604 byteskibblewhite

Comments

nevets’s picture

The blank screen suggests you have an error in PHP code. I can not read the patch file so the likely sources are a typo or re-declaring a function name. You might also try calling your module something other than 'module' since there are functions that already start with module.

Paul Adler’s picture

I have exactly the same issue when I try to use the block hook in a module I am creating. I have tried removing all other optional modules, plus removed all the other code from my module except the declaration of the block hook function and still all my blocks are not visible (they all show up in the lists on the admin block page, but not in the sidebars etc). As soon as I remove the block hook function, all the blocks are visible again. There are no errors in my drupal log files.

I am using Drupal 5.1.

Paul Adler’s picture

Kibble, Try renaming the directory that your theme uses and then enabling this new theme. This appears to work for me - let me know if this fixes your problem. I noticed that the blocks are related to a theme in the block table and this led me to investigating theme related issues.

mCode’s picture

I had the same problem. In my case, the issue was that I used the same name for the module and for the theme, and for some reason the $sidebar_left content arrives empty in page.tpl.php.

So, the workaround I think is to rename either the theme or the module.

kibblewhite’s picture

Ahhh, 'mCode', yes that works. My module had the same name as the theme I was using and caused a few issues.
Renaming the theme, [or you can do it the other way around] resolved this issue.

How strange, not that it's a big problem, but does anyone know if this is a known issue and getting sorted, thus allowing modules and themes to be named the same?

Thanks people for your replies...

jguffey’s picture

Version: 5.1 » 6.14

This Issue is quite old, just wanted to inform anyone else who finds this like I did,

Seems the problem is still in Drupal 6, and the solution here works in 6 as well as in 5, you cannot name your module and theme the same thing. It broke for me when I implemented hook_block.

bradweikel’s picture

Category: bug » support
Status: Active » Closed (fixed)

I opened kibble's attachment, and this is a standard trailing whitespace error.

kibble:
It is unnecessary to close php files with a php closing tag (ie "?>"), and doing so will often cause a WSOD (white screen of death) in Drupal because any whitespace after the closing tag will trigger headers to be returned before Drupal is ready, which then causes a duplicate headers error when Drupal does return its own headers. It's a silly little nuisance, but just don't close your php files that way.

missym’s picture

Yep - same here. Block and module need different names or all the blocks disappear. Sometimes the blocks seem to work fine for a while and then suddenly disappear.

gagarine’s picture

Version: 6.14 » 6.17
Category: support » bug
Status: Closed (fixed) » Active

I confirm if you have a module with the same name than you theme all your blocks become crazy and just disappear. Make me a will why my module with just a simple hook_block didn't work.

grendzy’s picture

Status: Active » Closed (fixed)