hook_block 的 Drupal Pressflow 问题

发布于 2024-11-06 22:57:19 字数 1534 浏览 2 评论 0原文

我在干净的 Pressflow 安装中实现 hook_block 挂钩时遇到问题。由于某种原因,它总是为我的所有块输出 ArrayArray。原因是主题函数中的 $info 变量设置为:

["block"]=>
array(7) {
["function"]=>
string(10) "fwtb_block"
["include files"]=>
array(0) {
}
["type"]=>
string(12) "theme_engine"
["theme path"]=>
string(21) "sites/all/themes/fwtb"
["arguments"]=>
array(1) {
  ["block"]=>
  NULL
}
["theme paths"]=>
array(2) {
  [0]=>
  string(14) "modules/system"
  [1]=>
  string(21) "sites/all/themes/fwtb"
}
["preprocess functions"]=>
array(2) {
  [0]=>
  string(19) "template_preprocess"
  [1]=>
  string(25) "template_preprocess_block"
}

}

正如您所看到的,它被我的自定义 hook_block 方法覆盖。所以现在它认为应该使用我的 fwtb_block 方法来渲染块,该方法返回一个包含主题和内容的数组。这就是它打印 ArrayArray 的原因。知道这里出了什么问题吗?

这是我的 hook_block 实现:

function fwtb_block($op = 'list', $delta = 0, $edit = array()) {
switch ($op) {
  case 'list':
    $blocks['sidebar_description'] = array(
      'info' => t('Sidebar description'),
      'cache' => BLOCK_CACHE_GLOBAL,
      'status' => TRUE,
      'region' => 'left',
      'visibility' => 0,
      'custom' => FALSE
    );
    return $blocks;
  case 'configure':
    $form = array();
    return $form;
  case 'save':
    return;
  case 'view': default:
    switch ($delta) {
      case 'sidebar_description':
        $block['subject'] = t('block_subject');
        $block['content'] = t('block_description');
        break;
    }
    return $block;
}

}

亲切的问候, 大安

i'm having troubles with implementing the hook_block hook in a clean Pressflow installation. For some reason it always outputs ArrayArray for all my blocks. The reason for this is that the $info variable in the theme function is set to:

["block"]=>
array(7) {
["function"]=>
string(10) "fwtb_block"
["include files"]=>
array(0) {
}
["type"]=>
string(12) "theme_engine"
["theme path"]=>
string(21) "sites/all/themes/fwtb"
["arguments"]=>
array(1) {
  ["block"]=>
  NULL
}
["theme paths"]=>
array(2) {
  [0]=>
  string(14) "modules/system"
  [1]=>
  string(21) "sites/all/themes/fwtb"
}
["preprocess functions"]=>
array(2) {
  [0]=>
  string(19) "template_preprocess"
  [1]=>
  string(25) "template_preprocess_block"
}

}

as you can see this is overwritten with my custom hook_block method. So now it thinks blocks should be rendered using my fwtb_block method which returns an array containing the subject and the content. That's why it prints ArrayArray. Any idea what is going wrong here?

This is my hook_block implementation:

function fwtb_block($op = 'list', $delta = 0, $edit = array()) {
switch ($op) {
  case 'list':
    $blocks['sidebar_description'] = array(
      'info' => t('Sidebar description'),
      'cache' => BLOCK_CACHE_GLOBAL,
      'status' => TRUE,
      'region' => 'left',
      'visibility' => 0,
      'custom' => FALSE
    );
    return $blocks;
  case 'configure':
    $form = array();
    return $form;
  case 'save':
    return;
  case 'view': default:
    switch ($delta) {
      case 'sidebar_description':
        $block['subject'] = t('block_subject');
        $block['content'] = t('block_description');
        break;
    }
    return $block;
}

}

kind regards,
Daan

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

优雅的叶子 2024-11-13 22:57:20

重新审视我的设置后,我发现了问题所在。我有一个主题和一个同名的模块。这引起了一些冲突:/

After taking a fresh look to my setup i saw what the problem was. I had a theme and a module with the same name. This caused some conflicts :/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文