Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By C-Watootsi on
The snippet below prints out a list of nodes in a particular taxonomy term in a format like list:
Node title
» by User
$term_id = 78;
$list_length = 150;
$prev_year = '';
$result = db_query("SELECT n.nid, n.title, n.created, u.uid, u.name
FROM {node} n INNER JOIN {users} u ON n.uid = u.uid INNER JOIN {term_node} tn ON n.nid = tn.nid
WHERE tn.tid = %d ORDER BY n.created DESC LIMIT %d", $term_id, $list_length);
$output .= "<p>" . l($node->title, "node/$node->nid"). "<br>" .
"<small>» by " . l($node->name, "user/$node->uid") . "</small></p>";
}
print $output;
What SQL do I have to add to extract from the database the additional taxonomy terms on each node, and print them the output? eg
Node title
» by User, in taxonomy1, taxonomy2
Can't quite get the query right.