0

I don't remember where exactly my return needs to be. It had worked at one point, but stopped at a random time. Google'd and didn't find my answer.

function bobby_name_generator_block_view($delta = '') {
  switch ($delta) {
    case 'bobby_name_generator':
      $block['subject'] = t('Generate Bobby Name');
      if(user_access('access content')) {
        $block['content'] = drupal_get_form('bobby_name_generator_form'); // insert bobbyname variable here!
      }
      return $block;
  }
}
6
  • This looks OK... Is all of this in bobby_name_generator.module? And do you have bobby_name_generator_block_info() as well? Commented Jun 11, 2013 at 22:02
  • I would also suggest to set a $block['content'] for the users who don't have the 'access content' permission. For example, $block['content'] = '';
    – Elin Y.
    Commented Jun 11, 2013 at 22:05
  • marcvanged: yes, it is. I can enable the module. No, I have no hook_block_info() set. Will try that.
    – mgbellaire
    Commented Jun 11, 2013 at 22:41
  • Eлин Й.: I will also add that.
    – mgbellaire
    Commented Jun 11, 2013 at 22:42
  • added both of you guy's suggestions and they did not help
    – mgbellaire
    Commented Jun 11, 2013 at 22:50

1 Answer 1

2

Here is an example for hook_block_info found in examples module. This defines the existence of block and this will make the block show up in the block page. You could use hook_block_configure to provide additional fields for you block in block page and save the it using hook_block_save.

function example_block_info() {

  $blocks['example'] = array(
 'info' => t('Example: configurable text string'),
 'cache' => DRUPAL_CACHE_PER_ROLE,
 'status' => TRUE,
 'region' => 'sidebar_first',
 'visibility' => BLOCK_VISIBILITY_LISTED, 
 'pages' => 'node/*',
 );

return $blocks;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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