首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >tid中的节点id

tid中的节点id
EN

Stack Overflow用户
提问于 2015-03-14 13:45:01
回答 2查看 766关注 0票数 0

如何从tid中获取nid,这样我就可以使用node_load函数,然后使用Field_get_items来获取特定的字段。我首先使用了taxonomy_select_node(),但它提供了与该tid相关的所有节点的nids,但我需要特定包(内容类型)的nids,因此我只能显示该内容类型的内容。现在我正在使用Entityfieldquery,下面是我的代码:

if(isset($_GET['tid'])){ $id=($_GET['tid']); $query = new EntityFieldQuery(); $query->entityCondition('entity_type', 'node'); $query->entityCondition('bundle', 'escorts_product'); $query->propertyCondition('status', 1); $query->fieldCondition('field_description', NULL, $id, '='); $result = $query->execute(); print "<pre>";print_r($result);

这里,我想从我的内容类型escorts_product中获取特定$id=tidfield_description,但它给出了所有tids的数组结构,而不是我在参数中提到的特定tids的数组结构?

EN

回答 2

Stack Overflow用户

发布于 2015-03-14 14:40:52

$query->fieldCondition('field_description', NULL, $id, '=');

应该像这样替换行,它将会工作,

$query->fieldCondition('field_your_term_reference_field', tid, $id, '=');

然后你就可以很容易地获得nid了。

票数 0
EN

Stack Overflow用户

发布于 2017-01-19 20:21:56

这对我很管用

代码语言:javascript
复制
$termid = array(1); //Where you save term ID(s)
$nids = taxonomy_select_nodes($termid);
$products = array(); //Lets say nodes type is PRODUCT
if (!empty($nids)) {
    foreach ($nids as $nid => $value) {
        echo $products[$value] = node_load($value)->title; // Echo all the titles of related nodes of current term.
    }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29045885

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档