[support] Problem with hook_block on Drupal 6.x

Metzler, David metzlerd at evergreen.edu
Fri Sep 3 00:58:53 UTC 2010


The list function needs to return array(0 => array( ....)). 
That is you must have a delta.  It's good practice to make the delta be
a short string but it also can be numbers, with some side affects.  

See the example at http://api.drupal.org/api/function/hook_block/6



-----Original Message-----
From: support-bounces at drupal.org [mailto:support-bounces at drupal.org] On
Behalf Of Tim Gustafson
Sent: Thursday, September 02, 2010 5:26 PM
To: support at drupal.org
Subject: [support] Problem with hook_block on Drupal 6.x

Hi,

I've created a module whose sole purpose is to add a few banners to the
left region of our sites.  Here's the code I'm using:

function banners_block($op) {
  if ($op == "list") {
    return array(
      "banners" => array(
        "info" => "Banners",
        "cache" => BLOCK_NO_CACHE,
        "weight" => 50,
        "status" => 1,
        "region" => "left",
        "visibility" => 0,
        "pages" => "",
      ),
    );
  } else if ($op == "view") {
    return array(
      "subject" => "<none>",
      "content" => "<p>" . time() . "</p>\n",
    );
  }
}

However, when I activate this module, it does not appear in the blocks
configuration page and no content is added to the "left" region.  I've
emptied the cache, logged out and back in again, run cron, and nothing
appears.  If I put a little debug line like:

echo ".";

right after the 'if ($op == "list") {' line, it does display a period at
the top of each page, so I'm sure that the module is being loaded and
executed.  It's just not displaying the block anywhere.  If I put a
similar debug line after the '$op == "view"' line, no dot gets displayed
on any page.

Am I doing something wrong?

Tim Gustafson
Baskin School of Engineering
UC Santa Cruz
tjg at soe.ucsc.edu
831-459-5354

--
[ Drupal support list | http://lists.drupal.org/ ]


More information about the support mailing list