You are here

function newsletter_get_template_terms in Newsletter 7

Same name and namespace in other branches
  1. 7.2 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.

2 calls 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.
newsletter_field_attach_form in ./newsletter.module
Implements hook_field_attach_form().

File

./newsletter.module, line 1207
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;
}