使用node_load函数。
参数如下:
$nid: The node ID.
$vid: The revision ID.
$reset: Whether to reset the node_load_multiple cache.
这样,可以输入node id,获取NODE数据,但是不能根据内容类型和类型下特定的字段属性来查。这时候,需要用EntityFieldQuery类(使用说明:http://drupal.org/node/1343708),查询一个NODE数据:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | <?php $query = new EntityFieldQuery(); $query->entityCondition('entity_type', 'node') ->entityCondition('bundle', 'article') ->propertyCondition('status', 1) ->fieldCondition('field_news_types', 'value', 'spotlight', '=') ->fieldCondition('field_photo', 'fid', 'NULL', '!=') ->fieldCondition('field_faculty_tag', 'tid', $value) ->fieldCondition('field_news_publishdate', 'value', $year. '%', 'like') ->range(0, 10) ->addMetaData('account', user_load(1)); // Run the query as user 1. $result = $query->execute(); if (isset($result['node'])) { $news_items_nids = array_keys($result['node']); $news_items = entity_load('node', $news_items_nids); } ?> |
不错,多谢分享。
实用,简洁,非常感谢