0

我有一个先前的问题,结合了关于这个主题的两个问题......但我想我解释得有点含糊......故事太多......所以我一次只问一个问题:)

我想知道如何使用 Drupal 7 中的规则检查分类术语是否存在。我想我需要使用自定义 PHP 规则和原生 Drupal 函数(类似于 check_if_term_exists() ?)。

但我似乎找不到正确的方法来做到这一点。

4

1 回答 1

2

好,易于:

$tid = 5; // The term ID, you can't load by term name as such because multiple terms may have the same name within different (and even within the same) vocabularies.
$term = taxonomy_term_load($tid);

if ($term) {
  // The term exists
}
else {
  // The term doesn't exist
}
于 2011-10-18T07:43:52.743 回答