I've created a module which creates 2 blocks.
function my_module_block_info() {
$blocks['blockA'] = array(
'info' => t('blockA'),
'cache' => DRUPAL_CACHE_PER_ROLE,
);
$blocks['blockB'] = array(
'info' => t('blockB'),
'cache' => DRUPAL_CACHE_PER_ROLE,
);
return $blocks;
}
function my_module_block_view($delta = '') {
switch ($delta) {
case 'blockA':
$block['subject'] = t('subjectA');
if (user_access('access content')) {
$block['content'] = 'HelloA';
}
return $block;
break;
case 'blockB':
$block['subject'] = t('subjectB');
if (user_access('access content')) {
$block['content'] = 'HelloB';
}
return $block;
break;
}
Everything good so far. Here is my question:
I would like developers to create blocks using the same module (20 more blocks). How can I add a new block with its view without modifying the my_module.module? Is there a way to extend and include .php files that declare other blocks? So, instead of having a huge my_module.module file, I can have multiples .php files (one for each block).
Thank you in advance