t('An exciting block provided by Mymodule.'), 'weight' => 0, 'status' => 1, 'region' => 'left', // BLOCK_CACHE_PER_ROLE will be assumed for block 0. ); $blocks['amazing'] = array( 'info' => t('An amazing block provided by Mymodule.'), 'cache' => BLOCK_CACHE_PER_ROLE | BLOCK_CACHE_PER_PAGE, ); return $blocks; } /** * Configuration form for the block. * * Any module can export a block (or blocks) to be displayed by defining * the _block hook. This hook is called by theme.inc to display a block, * and also by block.module to procure the list of available blocks. * * @param $delta * Which block to return. This is a descriptive string used to identify * blocks within each module and also within the theme system. * The $delta for each block is defined within the array that your module * returns when the hook_block_list() implementation is called. * @return * Optionally return the configuration form. * * After completing your blocks, do not forget to enable them in the * block admin menu. * * For a detailed usage example, see block_example.module. */ function hook_block_configure($delta = '') { if ($delta == 'exciting') { $form['items'] = array( '#type' => 'select', '#title' => t('Number of items'), '#default_value' => variable_get('mymodule_block_items', 0), '#options' => array('1', '2', '3'), ); return $form; } } /** * Save the configuration options. * * Any module can export a block (or blocks) to be displayed by defining * the _block hook. This hook is called by theme.inc to display a block, * and also by block.module to procure the list of available blocks. * * @param $delta * Which block to save the settings for. This is a descriptive string used * to identify blocks within each module and also within the theme system. * The $delta for each block is defined within the array that your module * returns when the hook_block_list() implementation is called. * @param $edit * The submitted form data from the configuration form. * * After completing your blocks, do not forget to enable them in the * block admin menu. * * For a detailed usage example, see block_example.module. */ function hook_block_save($delta = '', $edit = array()) { if ($delta == 'exciting') { variable_set('mymodule_block_items', $edit['items']); } } /** * Process the block when enabled in a region in order to view its contents. * * Any module can export a block (or blocks) to be displayed by defining * the _block hook. This hook is called by theme.inc to display a block, * and also by block.module to procure the list of available blocks. * * @param $delta * Which block to return. This is a descriptive string used to identify * blocks within each module and also within the theme system. * The $delta for each block is defined within the array that your module * returns when the hook_block_list() implementation is called. * @return * An array which must define a 'subject' element and a 'content' element * defining the block indexed by $delta. * * The functions mymodule_display_block_exciting and _amazing, as used in the * example, should of course be defined somewhere in your module and return the * content you want to display to your users. If the "content" element is empty, * no block will be displayed even if "subject" is present. * * After completing your blocks, do not forget to enable them in the * block admin menu. * * For a detailed usage example, see block_example.module. */ function hook_block_view($delta = '') { switch ($delta) { case 'exciting': $block = array( 'subject' => t('Default title of the exciting block'), 'content' => mymodule_display_block_exciting(), ); break; case 'amazing': $block = array( 'subject' => t('Default title of the amazing block'), 'content' => mymodule_display_block_amazing(), ); break; } return $block; } /** * @} End of "addtogroup hooks". */