Hello all,
I'm currently working on the D7 version of FAQ_Ask where I am trying to get my head around the fielding of the taxonomy term stuff. In my code I'm building a query that will leave me with a set of unpublished nodes (could be created by anonymous users) linked to a set of terms in given vocabularies.

// Find the vocabulary to search for...
  $vocabulary = taxonomy_vocabulary_load_multiple(variable_get('faq_ask_vocabularies', 0));

  // Join the term_data table to select based on tid.
  $query = db_select('node', 'n');
  foreach($vocabulary as $vid => $vocObj) {
      $query->leftJoin('field_data_field_tags', 'ft', "n.nid=ft.entity_id OR ft.entity_id IS NULL");
  }
  $query->addField('n', 'nid');
  $query->addField('ft', 'field_tags_tid', 'tid');  // tid
  $query->condition('n.status', 0);   // Not published
  $query->condition('n.type', 'faq');  // n.type = 'faq' (this is a 'faq' node)
  $result = $query->execute();

The query worked for the "tags" vocabulary and hard-coding the table name to field_data_field_tags , but when trying to use any vocabulary and variably finding the table name, I'm a little stuck.
Any idea how I can get a result set where the result is given by a set of terms?
/Sten

Comments

Version: 7.10 » 7.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.

Status: Active » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.