You are here

function _acquia_lift_get_mapped_taxonomy_context in Acquia Lift Connector 7.3

Gets the list of taxonomy terms applied for a particular node and particular taxonomy vocabularies.

Parameters

$node: The node that is being displayed

string $vocabulary_machine_name: The machine name of the vocabulary

Return value

null if no mapping, a string of terms if mapping exists.

1 string reference to '_acquia_lift_get_mapped_taxonomy_context'
_acquia_lift_get_mapping_callbacks in ./acquia_lift.context.inc
Gets all the callbacks for finding the mapped value of a context type. The callback receives the the node and the mapped value.

File

./acquia_lift.context.inc, line 147
acquia_lift.context.inc Provides functions needed for handling visitor contexts.

Code

function _acquia_lift_get_mapped_taxonomy_context($node, $vocabulary_machine_name) {
  if (empty($node) || empty($vocabulary_machine_name)) {
    return null;
  }
  $mapped = array();
  $results = db_query('SELECT tid FROM {taxonomy_index} WHERE nid = :nid', array(
    ':nid' => $node->nid,
  ));
  $terms = taxonomy_term_load_multiple($results
    ->fetchCol());
  foreach ($terms as $term) {
    if ($term->vocabulary_machine_name !== $vocabulary_machine_name) {
      continue;
    }
    $mapped[] = $term->name;
  }
  return implode(',', $mapped);
}