我想创建一个包含来自page.tpl.php
的$ tabs的块/**
* Implements hook_block_info().
*/
function mymodule_block_info() {
$blocks['tabs'] = array(
'info' => t('Tabs in block'),
'description' => t('blah blah blah'),
);
return $blocks;
}
/**
* Implements hook_block_view().
*/
function mymodule_block_view($delta = '') {
$block = array();
switch ($delta) {
case 'tabs':
$block['subject'] = t("THIS IS ZHE TABS!");
$block['content'] = array(
'#theme' => 'menu_local_tasks',
'#primary' => menu_local_tasks(0),
'#secondary' => menu_local_tasks(1),
);
break;
}
return $block;
}
该块正在正确注册,并且正在显示正确的选项卡。但是,Drupal会抛出很多错误!
Warning: Invalid argument supplied for foreach() in element_children() (line 6300 of /Users/tolborg/Sites/bibdk/includes/common.inc).
Warning: Cannot use a scalar value as an array in drupal_render() (line 5767 of /Users/tolborg/Sites/bibdk/includes/common.inc).
Warning: Cannot use a scalar value as an array in drupal_render() (line 5822 of /Users/tolborg/Sites/bibdk/includes/common.inc).
Warning: Invalid argument supplied for foreach() in element_children() (line 6300 of /Users/tolborg/Sites/bibdk/includes/common.inc).
Warning: Illegal string offset '#children' in drupal_render() (line 5767 of /Users/tolborg/Sites/bibdk/includes/common.inc).
Warning: Illegal string offset '#children' in drupal_render() (line 5777 of /Users/tolborg/Sites/bibdk/includes/common.inc).
Warning: Illegal string offset '#children' in drupal_render() (line 5815 of /Users/tolborg/Sites/bibdk/includes/common.inc).
Warning: Illegal string offset '#printed' in drupal_render() (line 5822 of /Users/tolborg/Sites/bibdk/includes/common.inc).
Warning: Invalid argument supplied for foreach() in element_children() (line 6300 of /Users/tolborg/Sites/bibdk/includes/common.inc).
Warning: Cannot use a scalar value as an array in drupal_render() (line 5767 of /Users/tolborg/Sites/bibdk/includes/common.inc).
Warning: Cannot use a scalar value as an array in drupal_render() (line 5822 of /Users/tolborg/Sites/bibdk/includes/common.inc).
Warning: Invalid argument supplied for foreach() in element_children() (line 6300 of /Users/tolborg/Sites/bibdk/includes/common.inc).
Warning: Illegal string offset '#children' in drupal_render() (line 5767 of /Users/tolborg/Sites/bibdk/includes/common.inc).
Warning: Illegal string offset '#children' in drupal_render() (line 5777 of /Users/tolborg/Sites/bibdk/includes/common.inc).
Warning: Illegal string offset '#children' in drupal_render() (line 5815 of /Users/tolborg/Sites/bibdk/includes/common.inc).
Warning: Illegal string offset '#printed' in drupal_render() (line 5822 of /Users/tolborg/Sites/bibdk/includes/common.inc).
答案 0 :(得分:0)
似乎问题出在主题函数中,也许。
我尝试使用此功能
$tabs = menu_local_tasks(0);
$block['content'] = $tabs['tabs']['output'];
答案 1 :(得分:0)
模块blockify可以完成此任务并为您创建其他page.tpl.php元素。它还为管理页面提供了“阻塞”
的元素