You are here

function _taxonomy_menu_get_node_terms in Taxonomy menu 7

Same name and namespace in other branches
  1. 8 taxonomy_menu.database.inc \_taxonomy_menu_get_node_terms()
  2. 6.2 taxonomy_menu.database.inc \_taxonomy_menu_get_node_terms()
  3. 7.2 taxonomy_menu.database.inc \_taxonomy_menu_get_node_terms()

Gets an array of the tid's related to the node

Parameters

object $node: Node object.

Return value

array Array of taxonomy term IDs.

4 calls to _taxonomy_menu_get_node_terms()
taxonomy_menu_node_delete in ./taxonomy_menu.module
Implements hook_node_delete().
taxonomy_menu_node_insert in ./taxonomy_menu.module
Implements hook_node_insert().
taxonomy_menu_node_presave in ./taxonomy_menu.module
Implements hook_node_presave().
taxonomy_menu_node_update in ./taxonomy_menu.module
Implements hook_node_update().

File

./taxonomy_menu.database.inc, line 88
Database functions

Code

function _taxonomy_menu_get_node_terms($node) {

  // Get the taxonomy fields.
  $tids = array();
  $result = db_query("SELECT field_name FROM {field_config} WHERE type = 'taxonomy_term_reference'");
  foreach ($result as $field) {
    $field_name = $field->field_name;
    if (isset($node->{$field_name})) {
      $tid_field = $node->{$field_name};

      // Loop through all the languages.
      foreach ($tid_field as $tid_field_languages) {

        // Loop through all the tids
        foreach ($tid_field_languages as $tid) {
          $tids[] = $tid['tid'];
        }
      }
    }
  }
  return $tids;
}