首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用实体字段查询获取nids

使用实体字段查询获取nids
EN

Stack Overflow用户
提问于 2015-04-11 14:03:33
回答 1查看 727关注 0票数 0

我想要所有的奶子,但我拿不到。下面是我的片段。

代码语言:javascript
复制
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node');
$query->entityCondition('bundle', 'product');
$query->propertyCondition('status', 1);
$query->fieldCondition('field_product_sub_cat', 'tid',array($leaf_nodes));
$query->range(0, 10);
$result = $query->execute();
if (isset($result['node']))
{
  $product_childnid = array_keys($result['node']);
}

下面是我的result:UPDATED

代码语言:javascript
复制
Array
(
[node] => Array
    (
        [78] => stdClass Object
            (
                [nid] => 78
                [vid] => 78
                [type] => product
            )

        [80] => stdClass Object
            (
                [nid] => 80
                [vid] => 80
                [type] => product
            )

        [82] => stdClass Object
            (
                [nid] => 82
                [vid] => 82
                [type] => product
            )

        [84] => stdClass Object
            (
                [nid] => 84
                [vid] => 84
                [type] => product
            )

        [86] => stdClass Object
            (
                [nid] => 86
                [vid] => 86
                [type] => product
            )

        [88] => stdClass Object
            (
                [nid] => 88
                [vid] => 88
                [type] => product
            )

        [90] => stdClass Object
            (
                [nid] => 90
                [vid] => 90
                [type] => product
            )

        [92] => stdClass Object
            (
                [nid] => 92
                [vid] => 92
                [type] => product
            )

        [94] => stdClass Object
            (
                [nid] => 94
                [vid] => 94
                [type] => product
            )

        [100] => stdClass Object
            (
                [nid] => 100
                [vid] => 100
                [type] => product
              )
          )
  )

下面的代码也为我提供了所有的路径,

代码语言:javascript
复制
$paths = array();
if (isset($result['node']))
{
 foreach($result['node'] as $key => $node) 
 {
 $paths[$node->nid] = drupal_get_path_alias("node/$node->nid");
 }
}

现在,下一个问题是如何在锚标记中表示这些路径?因为它们都在array.Below中,是路径别名的数组结构:

代码语言:javascript
复制
Array
(
 [78] => equivalent-fireman-glove-details
 [80] => toughguard®-2
 [82] => toughguard®-3
 [84] => toughguard-®sizzler®
 [86] => tough-guard-®
 [88] => kevlar®-double-glove
 [90] => nomex®-industrial-coverall
 [92] => tough-guard®-clinker®-0
 [94] => lab-coats-sa-nlc
)

下面是与上述路径链接的数组结构数据:

代码语言:javascript
复制
Array
(
 [0] => 71
 [1] => 73
 [2] => 81
 [3] => 83
 [4] => 85
 [5] => 87
 [6] => 89
 [7] => 91
 [8] => 93
) 
EN

回答 1

Stack Overflow用户

发布于 2015-04-11 20:07:21

试试这个:

代码语言:javascript
复制
$query->fieldCondition('field_product_sub_cat', 'tid',array($leaf_nodes),'IN');

以便将查询的值与数组进行比较。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29578757

复制
相关文章

相似问题

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