You are here

function taxonomy_tools_menu_alter in Taxonomy Tools 8

Same name and namespace in other branches
  1. 7 taxonomy_tools.module \taxonomy_tools_menu_alter()

Implements hook_menu_alter().

File

./taxonomy_tools.module, line 104
Drupal hooks and functions to work with taxonomy terms.

Code

function taxonomy_tools_menu_alter(&$items) {
  $use_view = FALSE;
  if (module_exists('views')) {
    $views = views_get_enabled_views();
    foreach ($views as $view) {
      foreach ($view->display as $display) {
        if (isset($display->display_options['path']) && $display->display_options['path'] == 'taxonomy/term/%') {

          // If term page path is used by a view.
          $items['taxonomy/term/%views_arg']['access callback'] = 'taxonomy_tools_taxonomy_term_access';
          $items['taxonomy/term/%views_arg']['access arguments'] = array(
            2,
          );
          $use_view = TRUE;
          break 2;
        }
      }
    }
  }
  if (!$use_view) {
    $items['taxonomy/term/%taxonomy_term']['access callback'] = 'taxonomy_tools_taxonomy_term_access';
    $items['taxonomy/term/%taxonomy_term']['access arguments'] = array(
      2,
    );
  }
}