hook_theme() 不传递参数

发布于 2024-09-27 13:57:27 字数 1326 浏览 2 评论 0原文

我目前编写了一个生成块的模块。输出应该由模板定义。没什么特别的,但争论似乎没有得到正确的通过。

这是主题方法:

/* # Theme {{{*/
function browse_by_taxonomy_theme() {
  return array(
    'browse_by_taxonomy_block' => array(
      'template' => 'browse_by_taxonomy_block',
      'arguments' => array(
        'next' => null,
        'previous' => null,
        'term' => null,
        'hide_if_null' => variable_get('browse_by_taxonomy_hide_links', false)
      )
    )
  );
}/*}}}*/

它的调用方式如下:

$block['content'] = theme('browse_by_taxonomy_block', "next", "previous", $tid);

即使我将其设置为最小值,它也不起作用:

function browse_by_taxonomy_block($op = 'list', $delta = 0, $edit = array()) {  
  switch ($op) {
    case 'list':
      $block = array(array('info' => t("Browse by taxonomy")));
      return $block;

    case 'view':
      # […] Dragons be here
      return array(
        'subject' => null, 
        'content' => theme('browse_by_taxonomy_block', "next", "previous", "p")
      );
  }
}/*}}}*/

但在我的模板中,一切都是null

var_dump($previous); # => NULL
var_dump($next); # => NULL
var_dump($hide_if_null); # => NULL
var_dump($term); # => NULL

在我编写的另一个模块中,我以几乎相同的方式完成了它并且它有效。这次我做错了什么?

I currently write a module that generates a block. The output should be defined by a template. Nothing special, yet the arguments don't seem to get passed properly.

This is the theme-method:

/* # Theme {{{*/
function browse_by_taxonomy_theme() {
  return array(
    'browse_by_taxonomy_block' => array(
      'template' => 'browse_by_taxonomy_block',
      'arguments' => array(
        'next' => null,
        'previous' => null,
        'term' => null,
        'hide_if_null' => variable_get('browse_by_taxonomy_hide_links', false)
      )
    )
  );
}/*}}}*/

And it's being called like that:

$block['content'] = theme('browse_by_taxonomy_block', "next", "previous", $tid);

Even when i put it to the minimum of this it does not work:

function browse_by_taxonomy_block($op = 'list', $delta = 0, $edit = array()) {  
  switch ($op) {
    case 'list':
      $block = array(array('info' => t("Browse by taxonomy")));
      return $block;

    case 'view':
      # […] Dragons be here
      return array(
        'subject' => null, 
        'content' => theme('browse_by_taxonomy_block', "next", "previous", "p")
      );
  }
}/*}}}*/

But in my template everything is null

var_dump($previous); # => NULL
var_dump($next); # => NULL
var_dump($hide_if_null); # => NULL
var_dump($term); # => NULL

In another module i wrote i did it pretty much the same way and it works. What am I doning wrong this time?

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

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

发布评论

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

评论(2

末が日狂欢 2024-10-04 13:57:27

该问题很可能是由缓存问题引起的,因为 Drupal 出于性能原因缓存了所有主题信息。

Most likely the problem is caused by caching issues, as Drupal caches all theme info for performance reasons.

岁月如刀 2024-10-04 13:57:27

在这种情况下,缓存是魔鬼,我的朋友......只需刷新您的主题,它很可能会起作用。至少在我的情况下是这样的,经过长时间的搜索,充满了咒骂和咒骂,我终于尝试了,宾果......

Caching is the devil in this case my frend... just refresh your theme and it will most likely work. That was the thing in my case atleast, after a long long long search filled with lots of cursing and swearing I finally tried that and BINGO...

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