Drupal 10 仅当内容具有特定术语时才阻止可见性

问题描述 投票:0回答:1

我已经7年没有使用Drupal了 仅当特定分类(词汇)中有特定术语时,我才希望块的可见性

Vocabulary

所以我进去只能选择整个词汇

category

在这种情况下,我想在“类别”中选择一个术语。

解决方案可以使用 PHP

enter image description here

类似...

<?PHP 
if content taxonomyid=8
return TRUE; ?>

但是我忘了怎么做。

drupal settings block drupal-10
1个回答
0
投票

我找到了这个,但不起作用

  $myterm = "mixes";  
  if ((arg(0) == 'node') && is_numeric(arg(1))) {
    $terms = taxonomy_node_get_terms(arg(1));
    foreach($terms as $term) {
      if ($term->name == $myterm) return TRUE;
    }
  }
© www.soinside.com 2019 - 2024. All rights reserved.