How to define multiple blocks in a module? Thanks to this tutorial, I cam up with this block-generating module:



function myblockmodule_block_info(){
    $block['myadblocks'] = array(
        'info' =&gt; t('My first ad blcoks'),
        'cache' =&gt; DRUPAL_NO_CACHE,
    );
    return $block;
}

/**
 * Define what our block is going to look like.
 * Implements hook_block_view().
 */
function myblockmodule_block_view($block_key){
    $block = array();

    if($block_key == 'myadblocks'){ //We only want to define the content of OUR block
        //This is the title of the block.
        $block['subject'] = t('First ad block comes here');

        //Define the block content.
        $block['content'] = 'some fancy script comes here';
    }

    return $block;
}


I am wondering how to extend the module to create 2 blocks instead of one?
Simple as:

function myblockmodule_block_info(){
    $block['myadblocks'] = array(
        'info' =&gt; t('My first ad blcoks'),
        'cache' =&gt; DRUPAL_NO_CACHE,
    );

    $block['myadblocks2'] = array(
        'info' =&gt; t('My second ad blcoks'),
        'cache' =&gt; DRUPAL_NO_CACHE,
    );
    return $block;
}

/**
 * Define what our block is going to look like.
 * Implements hook_block_view().
 */
function myblockmodule_block_view($block_key){
    $block = array();

    if($block_key == 'myadblocks'){ //We only want to define the content of OUR block
        //This is the title of the block.
        $block['subject'] = t('First ad block comes here');

        //Define the block content.
        $block['content'] = 'some fancy script comes here';
    }
    elseif ($block_key == 'myadblocks2') {
      $block['subject'] = t('Foo');
      $block['content'] = 'var';
    }

    return $block;
}


And clear the caches.