You are here

function taxonomy_facets_get_nodes in Taxonomy Facets 7.3

1 call to taxonomy_facets_get_nodes()
taxonomy_facets_get_nodes_based_on_intersect_of_terms in ./taxonomy_facets.module
Get nodes tagged by given terms.

File

./taxonomy_facets.module, line 483

Code

function taxonomy_facets_get_nodes($tids, $node_types, $text_compare = NULL, $text_compare_middle = NULL) {
  $query = db_select('node', 'n')
    ->fields('n', array(
    'nid',
  ));
  $cnt = 0;
  foreach ($tids as $key => $value) {
    $query
      ->innerJoin('taxonomy_index', 'ti' . $cnt, 'n.nid = ti' . $cnt . ' .nid ');
    $query
      ->condition('ti' . $cnt . '.tid', $value);
    $cnt++;
  }
  $query
    ->condition('status', 0, '>')
    ->condition('n.type', $node_types, 'IN')
    ->orderBy('n.sticky', 'DESC')
    ->orderBy('n.created', 'DESC');
  return $query
    ->execute()
    ->fetchAll();
}