Answers:
以下代码应该有所帮助。显然,您需要适当地添加5个块,但这只是说明如何在一个模块中添加多个块:
function MYMODULE_block_info() {
$blocks = array();
$blocks['myfirstblock'] = array(
'info' => t('My block admin info'),
'status' => 1,
);
$blocks['mysecondblock'] = array(
'info' => t('My second block admin info'),
'status' => 1,
);
return $blocks;
}
function MYMODULE_block_view($delta = '') {
$block = array();
switch ($delta) {
case 'myfirstblock':
$block = array(
'subject' => t('My first block title'),
'content' => t('My first block content'),
);
break;
case 'mysecondblock':
$block = array(
'subject' => t('My second block title'),
'content' => t('My second block content'),
);
break;
}
return $block;
}
原因status => 1
从hook_block_info()
API文档:
status :(可选)块启用状态的初始值。(1 =启用,0 =禁用)。大多数模块不提供初始值,并且用户可以在块组态屏幕上修改提供的任何值。
我不确定每个模块的想法是从哪里得到的。您可以在模块中创建任意数量的块。