I'm trying to create a block that comes with a drupal module. I can't get it to show up in my block list. I tried a lof of different tutorials, even just copy paste and it still doesn't show up. Could it be anything in my drupal settings that stops my modules block from showing up? Or is there anything wrong in the code?

The module shows and is activated.

This is my code right now:

helicopter_contest_form.info

;$Id$

name = Helicopter contest form
description = Block module with a contest form
core = 7.x
package = Bredband2
files[] = helicopter_contest_form.module

helicopter_contest_form.module


/**
 * Implements hook_block_info().
 */
function membercount_block_info() {
  $blocks = array ();
 
  $blocks['count_members'] = array (
    'info' => t('Count Members'),
    'cache' => DRUPAL_NO_CACHE,
  );
 
  return $blocks;
}

/**
 * Implements hook_block_view().
 */
function membercount_block_view($name) {
 
  if ($name == 'count_members') {
    $count = db_query('SELECT COUNT(uid) - 1 FROM {users}')->fetchField();
 
    $content = format_plural($count, 'This site has 1 user.', 'This site has @count users.');
 
    $block = array (
      'subject' => t('Members'),
      'content' => $content,
    );
 
    return $block;
  }
}

Comments

abhishek sawant’s picture

You need to replace "membercount" with your actual MODULENAME i.e. "helicopter_contest_form" in all fucntions under .module file. After that just clear the cache or disable/enable the module, now you will be able to list your custom block under structure>>block.

Hope it helps.

Abhishek Sawant
Drupal Developer