0

以前、このテーマに関する 2 つの質問を組み合わせた質問がありました...しかし、少しあいまいな説明をしたと思います...話が多すぎます...だから、一度に 1 つの質問だけをします :)

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 に答える