Skip to content

Instantly share code, notes, and snippets.

@batandwa
Created June 12, 2014 13:06
Show Gist options
  • Save batandwa/84bb5e680422fe591771 to your computer and use it in GitHub Desktop.
Save batandwa/84bb5e680422fe591771 to your computer and use it in GitHub Desktop.
Drupal 7 - Custom block hooks
<?php
/**
* Implements hook_block_info().
*/
function YOUR_MODULE_block_info() {
$blocks = array();
$blocks['YOUR_BLOCK_ABC'] = array(
'info' => t('YOUR BLOCK NAME'),
);
return $blocks;
}
/**
* Implements hook_block_view().
*/
function YOUR_MODULE_block_view($delta = '') {
$block = array();
switch ($delta) {
case 'YOUR_BLOCK_ABC':
$block['subject'] = '';
$block['content'] = _YOUR_MODULE_BLOCK_ABC_CONTENT();
break;
}
return $block;
}
function _YOUR_MODULE_BLOCK_ABC_CONTENT() {
$output = t('Hello world');
return $output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment