Frage

I created a custom block for my Drupal 7 install like this:

/*
 * Implements hook_block_info
 * To create a block to display the information for planB in the footer.
 */

function planb_block_info() {
  $blocks['planb_footer'] = array(
    'info' => t('PlanB Footer'),
    'status' => true,
    'weight' => 0,
    'visibility' => 1,
  );
  return $blocks;
}

function planb_block_view($delta = '') {
  switch($delta) {
    case 'planb_footer':
      $block['subject'] = NULL;
      $block['content'] = footer_block_content($delta);
      return $block;
      break;
  } 
}

function footer_block_content($delta) {
  return array('#markup' => theme('footer'));
}

Now, in my local testing environment the footer appears correctly. However, when I upload the module file to the production environment the footer doesn't appear anywhere. It doesn't even appear on the Blocks page, it's almost as if the hook is not registering with Drupal. Does anyone have any idea what I might have overlooked?

I've cleared the cache.

War es hilfreich?

Lösung

I've still not found out what was wrong with this but instead reverted to creating a footer via the GUI in the Drupal administration.

Andere Tipps

I often have the same issue when installing a custom module in another environment. It only happens when the block has no set region, so my workaround is to move the block with Drush after installing and enabling the module. When the region is set, the block appears in the admin view.

drush block-configure --module=MY_MODULE --delta=BLOCK_DELTA --region=TARGET_REGION chdir="/PATH/TO/DRUPAL"

The missing block also tends to appear if I change delta name, but obviously that's not worth the hassle when you're deploying to several environments.

ETA: block-configure is included in the drush_extras package, available for Drush 7.

It might be a cache issue : did you clear your caches on the production server ? At least the class registry should be emptied for Drupal to register your new block.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top