Created
March 19, 2013 11:37
Revisions
-
bajanReece created this gist
Mar 19, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ <?php function get_taxonomy_content($tid, $limit = 10) { /** A note on variables: field_data_field_article_rating --- this is the name of taxonomy table you're referring to field_article_rating_tid --- this is the name of the term ID column in the table above **/ $out = array(); $query = db_select('node', 'n'); $query->join('field_data_field_article_rating', 'c', 'n.nid = c.entity_id'); $query->condition('n.status', 1, '=') ->condition('c.field_article_rating_tid', $tid) ->fields('n', array('nid', 'title')) ->orderBy('n.type', 'ASC'); $query = $query->extend('PagerDefault')->limit($limit); $result = $query->execute(); foreach($result as $row){ // first we get the node content $nodeObj = node_view(node_load($row->nid),'teaser'); // then we get the node URL $options = array('absolute' => TRUE); $url = url('node/' . $row->nid, $options); // then we output an array $out[$row->nid] = array('nid'=>$row->nid, 'title'=>$row->title, 'obj'=>$nodeObj, 'url'=>$url); } // end foreach return $out; } ?>