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

发布于 2024-12-10 05:18:42 字数 320 浏览 0 评论 0原文

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

我想知道如何检查分类术语是否存在使用 Drupal 7 中的规则。 我想我需要使用自定义 PHP 规则和本机 Drupal 函数(例如 check_if_term_exists() 之类的东西?)来完成此操作。

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

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

零崎曲识 2024-12-17 05:18:42

又好又简单:

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

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
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文