0

I am running into an issue where my block won't show up in the admin section of my site. I've added it to example_block_info() where the other existing blocks are declared. I've also added content in example_block_view():

/*block_info*/

$blocks['example'] = array(
    'info' => 'Example',
    'status' => TRUE,
    'visibility' => BLOCK_VISIBILITY_LISTED,
    'pages' => 'example/1*',
            'cache' => DRUPAL_NO_CACHE
);

/*block_view*/

switch($delta){

...

    case 'example':
        $block['content'] = '
            //content
        ';
        break;

}

Am I missing something? All the other blocks show up and work fine. I can modify them as well. This one doesn't work/show up.

1
  • you don't show the rest of the blocks in the code... is there a duplicate name?
    – Geoff
    Jul 1 '14 at 4:57
1

Try the next code below, it work for me:

/**
 * implements hook_block_info().
 */
function mymodule_block_info() {
  $blocks['hello-message'] = array(
    'info' => t('Message'),
    'status' => TRUE,
    'visibility' => BLOCK_VISIBILITY_LISTED,
    'pages' => 'example/1*',
    'cache' => DRUPAL_NO_CACHE,
  );

  return $blocks;
}

/**
 * implements hook_block_view().
 */
function mymodule_block_view($delta = '') {
  $block = array();

  if ($delta == 'hello-message') {
    $block['subject'] = t('Message');
    $block['content'] = t('Hello World!');
  }

  return $block;
}

See https://api.drupal.org/api/examples/block_example%21block_example.module/7

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.