/**
 * Implementation of hook_menu_alter().
 */
function utility_menu_alter(&$menu) {

  if (isset($menu['taxonomy/term/%'])) {
    $menu['taxonomy/term/%']['page callback'] = 'utility_taxonomy_term_page';
    $menu['taxonomy/term/%']['access callback'] = 'utility_access_term_pages';
    $menu['taxonomy/term/%']['access arguments'] = array(2);    
  }
}

/**
 * Callback function for taxonomy/term/%.
 *
 * @param $tid
 *   The term id.
 * 
 * @return
 *   Themed page for a taxonomy term, specific to the term's vocabulary.
 */
function utility_taxonomy_term_page($tid) {

  $term = taxonomy_get_term($tid);
  $vocabulary = taxonomy_vocabulary_load($term->vid);
  //var_dump($vocabulary);
   switch($vocabulary->vid) {
    
	//naschval neexistujuca vocab aby to zatial zbytocne neprepisovalo
    case '4':
      // Returns a page themed by mymodule.
      drupal_set_title(check_plain($term->name));
	  return utility_subject_page($tid);
    default: 
      // Returns the default term page provided by taxonomy module.
      module_load_include('inc', 'taxonomy', 'taxonomy.pages');
      return taxonomy_term_page($tid);
  }
  
  
  
 // drupal_set_title(check_plain($term->name));
//	  return utility_subject_page($tid);
  
}
function utility_subject_page($tids, $result) {
  //drupal_add_css(drupal_get_path('module', 'taxonomy') .'/taxonomy.css');

  $output = '';

  // Only display the description if we have a single term, to avoid clutter and confusion.
  if (count($tids) == 1) {
    $term = taxonomy_get_term($tids[0]);
    $description = $term->description;

    // Check that a description is set.
    if (!empty($description)) {
      $output .= '<div class="taxonomy-term-description">';
      $output .= filter_xss_admin($description);
      $output .= '</div>';
    }
  }
  
$output .= views_embed_view('kateg_list2', 'block_2', $nid); ;
  //$output .= taxonomy_render_nodes($result);

  return $output;
}
/**
 * Access callback function for taxonomy/term/%.
 *
 * @param $tid
 *   The term id.
 * 
 * @return
 *   True if current user is granted access, FALSE otherwise.
 */
function utility_access_term_pages($tid) {
  
  $term = taxonomy_get_term($tid);
  $vocabulary = taxonomy_vocabulary_load($term->vid);

  
      return user_access('administer taxonomy');
   
}