Skip to content

Instantly share code, notes, and snippets.

@v1talii-dev
Last active August 29, 2016 13:32
Show Gist options
  • Save v1talii-dev/a88009b0ed0173daa9a91b1467aa381b to your computer and use it in GitHub Desktop.
Save v1talii-dev/a88009b0ed0173daa9a91b1467aa381b to your computer and use it in GitHub Desktop.
D7: programmatically create block
<?php
/**
* Implements hook_block_info();
*/
function hook_block_info() {
$blocks['test'] = array(
'info' => t('Description'),
'cache' => DRUPAL_NO_CACHE,
);
return $blocks;
}
/**
* Implements hook_block_view().
*/
function hook_block_view($delta) {
// Block view only "test".
if ($delta != 'test') {
return;
}
$block = array(
'title' => t('Title'),
'content' => 'Test',
);
return $block;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment