Created
September 7, 2013 23:07
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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