Вкладки в блоке

Я хочу создать блок, который содержит $tabs из page.tpl.php

/**
 * 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).

2 ответа

Кажется, проблема в функции темы, может быть.

Я пытался использовать это, и это работает

$tabs =  menu_local_tasks(0);
$block['content'] =  $tabs['tabs']['output'];

Существует модуль blockify, который выполняет эту задачу и создает другие элементы page.tpl.php для вас. Это также дает странице администратора, для каких элементов "блокировать"

Другие вопросы по тегам