提供自定义块的基本模块

custom_module.info

name = Custom Module
description = Creates a block containing a custom output.
core = 7.x

custom_module.module

/**
 * Initiates hook_block_info.
 *
 * Registers the block with Drupal.
 */
function custom_module_block_info() {
  $blocks = array();
    //Registers the machine name of the block.
  $blocks['custom_block'] = array(
      //Sets the human readable, administration name.
    'info' => t('Titania Price Widget'),
      //Tells Drupal not to cache this block.
      //Used if there is dynamic content.
    'cache' => DRUPAL_NO_CACHE,
  );
  return $blocks;
}

/**
 * Initiates hook_block_view().
 *
 * Sets the block title and content callback.
 */
function custom_module_block_view($delta = '') {
  $block = array();

  switch ($delta) {
      //Must be the machine name defined in the hook_block_info.
    case 'custom_block':
        //The blocks title.
      $block['subject'] = 'My custom block';
        //The string or function that will provide the content of the block.
      $block['content'] = custom_module_block_content(); 
      break;
  }

  return $block;
}

/**
 * Returns the content of the custom block.
 */
function custom_module_block_content() {
  $content = "This function only returns a string, but could do anything."

  return $content;
}