You are here

function newsletter_get_template_terms in Newsletter 7.2

Same name and namespace in other branches
  1. 7 newsletter.module \newsletter_get_template_terms()

Fetches the terms for a template.

Parameters

$ntid The template ntid.:

Return value

An array of term names keyed by their tids.

1 call to newsletter_get_template_terms()
NewsletterAutomated::getQuery in includes/newsletter.automated.inc
Builds a dynamic query that gets the current nodes to be sent with the current newsletter.

File

./newsletter.module, line 518
Defines menu items for newsletter administration, permissions and basic drupal hooks.

Code

function newsletter_get_template_terms($ntid) {
  $terms = array();
  $template = newsletter_template_load($ntid);
  $vocabularies = taxonomy_get_vocabularies();
  foreach ($vocabularies as $vocabulary) {
    if ($vocabulary->machine_name == 'newsletter_categories') {
      continue;
    }
    $vocabulary_field = field_get_items('newsletter_template', $template, 'field_' . $vocabulary->machine_name);
    if ($vocabulary_field) {
      foreach ($vocabulary_field as $values) {
        $term = taxonomy_term_load($values['tid']);
        if ($term) {
          $terms[$term->tid] = $term->name;
        }
      }
    }
  }
  return $terms;
}