如何检查一个术语是否存在规则- Drupal 7



我之前有一个关于这个主题的问题,包含两个问题…但我觉得我解释得有点模糊……故事太多了……所以我一次只问一个问题:)

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

但是我似乎找不到一个正确的方法来做这件事。

很简单:

$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
}

相关内容

最新更新