You are here

function taxonomy_title_preprocess_page in Taxonomy Title 6

Implementation of hook_preprocess_page().

Overrides title and head_title variables sent to template_preprocess.

File

./taxonomy_title.module, line 86
Enhanced control over the heading tag for the taxonomy term list pages.

Code

function taxonomy_title_preprocess_page(&$variables) {

  // Get the tid depending on the path.
  if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2)) && arg(2) > 0) {
    $tid = arg(2);
  }
  elseif (module_exists('uc_catalog') && arg(0) == 'catalog') {
    $tids = explode(' ', arg(1));
    if (is_numeric($tids[0]) && $tids[0] > 0) {
      $tid = $tids[0];
    }
  }
  if (!empty($tid)) {

    // Retrieve the title based on tid.
    $title = _taxonomy_title_get($tid);
    if (!empty($title)) {
      drupal_set_title($title);
      $term = taxonomy_get_term($tid);
      $settings = taxonomy_title_get_settings();
      $heading_settings = $settings['taxonomy_title_headings'];
      $page_title_settings = $settings['taxonomy_title_page_titles'];
      if ($new_title = drupal_get_title()) {

        // Set the heading.
        if ($heading_settings[$term->vid] != 0) {
          $variables['title'] = $new_title;
        }

        // Set the title.
        if ($page_title_settings[$term->vid] != 0 && !module_exists('page_title')) {
          $head_title = array(
            strip_tags($new_title),
            variable_get('site_name', 'Drupal'),
          );
          $variables['head_title'] = implode(' | ', $head_title);
        }
      }
    }
  }
}