Reputation: 78
I had a previous question combining two questions on this subject...but I think I explained a little bit vague...too much story...so I will ask just one question at a time :)
I would like to know how I can check if a taxonomy term exists with Rules in Drupal 7. I think I will need to do it with a custom PHP rule together with a native Drupal function (something like check_if_term_exists() ?).
But I cannot seem to find a correct way to do it.
Upvotes: 0
Views: 1765
Reputation: 36955
Nice and easy:
$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
}
Upvotes: 2