You are here

function taxonomy_manager_term_page in Taxonomy Manager 6.2

Same name and namespace in other branches
  1. 5 taxonomy_manager.module \taxonomy_manager_term_page()
  2. 6 taxonomy_manager.module \taxonomy_manager_term_page()

menu callback

replaces taxonomy_mangager_term_page, because we have to consider that the url may contain former merged terms, which no longer exists every given tid gets checked, if it has been merged. if yes, the tid gets replaced with tid of main term and afterwards passed to default taxonomy_manager_term_page

Parameters

$str_tids:

$depth:

$op:

1 string reference to 'taxonomy_manager_term_page'
taxonomy_manager_menu_alter in ./taxonomy_manager.module
Implementation of hook_menu_alter

File

./taxonomy_manager.module, line 255
Taxonomy Manager

Code

function taxonomy_manager_term_page($str_tids = '', $depth = 0, $op = 'page') {
  $tids = taxonomy_terms_parse_string($str_tids);
  if ($tids['operator'] == 'and' || $tids['operator'] == 'or') {
    $new_tids = array();
    foreach ($tids['tids'] as $tid) {

      //get cached main term, if not merged, returns 0
      $main_term = taxonomy_manager_merge_get_main_term($tid);
      $new_tids[] = $main_term ? $main_term : $tid;
    }
    if ($tids['operator'] == 'and') {
      $operator = ',';
    }
    else {
      if ($tids['operator'] == 'or') {
        $operator = '+';
      }
    }
    $new_tids_str = implode($operator, $new_tids);
    if (!function_exists('taxonomy_term_page')) {

      /**
       * including the taxonomy.pages.inc file shouldn't be necessary, because
       * TaxMan is correctly using hook_menu_alter to change the callback.
       * but in some combinations with other modules, which overwrite the menu
       * entry in hook_menu, calling taxonomy_term_page is causing an error.
       * the following lines are going to prevent the fatal error
       */
      $taxonomy_module_path = drupal_get_path('module', 'taxonomy');
      include_once $taxonomy_module_path . '/taxonomy.pages.inc';
    }
    return taxonomy_term_page($new_tids_str, $depth, $op);
  }
  else {
    drupal_not_found();
  }
}