Skip to content

Instantly share code, notes, and snippets.

@esafwan
Created September 7, 2013 23:07
Show Gist options
  • Save esafwan/6480209 to your computer and use it in GitHub Desktop.
Save esafwan/6480209 to your computer and use it in GitHub Desktop.
Create drupal block in code or programatically. The code has to be placed in module file.
<?php
/**
* Implements hook_block_info().
*/
function mymodule_block_info() {
$blocks = array();
$blocks['my_block'] = array(
'info' => t('Master News Sticky'),
);
return $blocks;
}
/**
* Implements hook_block_view().
*/
function mymodule_block_view($delta = '') {
$block = array();
switch ($delta) {
case 'my_block':
$block['subject'] = '';
$block['content'] = _mymodule_block_master_content();
break;
}
return $block;
}
//content that has to be passed to the block.
function _mymodule_block_master_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