【问题标题】:How to check if a term exists with rules - Drupal 7如何使用规则检查术语是否存在 - Drupal 7
【发布时间】:2011-10-18 06:43:32
【问题描述】:

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

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

但我似乎找不到正确的方法。

【问题讨论】:

    标签: drupal drupal-7 drupal-taxonomy drupal-rules


    【解决方案1】:

    又好又简单:

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

    【讨论】:

    • 嗨 Clive 感谢您的快速响应!关于您的回答,我还有一个问题:该术语已插入分类参考字段,因此它基本上仍然只是提交时的文本。它还没有术语ID是否正确?如果它还没有 ID……我有什么选择?干杯!蒂姆
    猜你喜欢
    • 2011-12-19
    • 2020-09-09
    • 2016-09-10
    • 1970-01-01
    • 2022-11-09
    • 1970-01-01
    • 1970-01-01
    • 2019-09-02
    • 1970-01-01
    相关资源
    最近更新 更多