hello, how can i get the hook of a custom block ? 

Comments

Jaypan’s picture

This question doesn't make sense in Drupal terminology, and you have provided basically no information about what you are trying to do. Maybe this can help.

Anonymous’s picture

And how can i get the machine name of the block ? 

wombatbuddy’s picture

Updated

There are two types of blocks:

1. Block that created with UI.
2. Block created with custom module.

To get the id (delta) of a block created with UI, open 'configure' window and see the url.
For instance, if the url is:
/admin/structure/block/manage/block/1/configure
Then the block id (delta) is 1.

See the screenshots:
https://i.imgur.com/7cXCsdQ.png
https://i.imgur.com/5ruOH3r.png

The id (delta) of a custom block is array key which is used in hook_block_info().
For instance if we create a custom block like this: 

/**
 * Implements hook_block_info().
 */
function my_module_block_info() {
  $blocks['my_custom_block'] = array(
    'info' => t('My custom block'),
    'cache' => DRUPAL_CACHE_PER_ROLE,
  );
  return $blocks;
}

Then the block id (delta) is 'my_custom_block'.
Now you can use this id (delta) to output some content.
(!!! Attention: this isn't work for the blocks created with UI, but only for custom blocks).
The example 

/**
 * Implements hook_block_view().
 */
function my_module_block_view($delta = '') {
  $block = array();
  switch($delta) {
    case 'my_custom_block' :
      $block['content'] = 'The content of my custom block';
      break;
  }
  return $block;
}

You can alter the both types of blocks using hook_block_view_alter().
The example 

/**
 * Implements hook_block_view_alter().
 */
function my_module_block_view_alter(&$data, $block) {
  switch ($block->delta) {
    case '1':
      $data['content'] = 'The content of the block created using UI';
      break;

    case 'my_custom_block':
      $data['content'] = 'The content of my custom block';
      break;
  }
}

For additional info see 'Building Custom Blocks with Drupal 7'.