Define a Drupal 7 Block in a module

The following code is used if you want to define a new block within a Drupal module. Replace hook_ with your modules name.

t('Block Description'),
return $blocks;

function hook_block_view($delta = '') {
$block = array();
switch ($delta) {
case 'block-name':
$block['content'] = hook_custom_function();
return $block;

function hook_custom_function(){
$content = "Block Content";
return $content;

Posted by

Leave a Reply