Alter title link in taxonomy view mode Under /admin/structure/taxonomy/my_vocabulary/display/entity I've got a view mode "entity". For this view mode, I would like to alter the way the link in the title field is built (the title is replaced by a real field instance due to title module): the link should be rebuilt into an anchor link like this: &lt;a href="#term-ID&gt;Title&lt;/a&gt;, where term-ID is replaced with the actul term ID of the term. How can I achieve this by a custom module or by a template function? Are render arrays good for this?
Here's a screenhot of the admin page.
I finally altered the title link by using a preprocess hook and a custom field template file (and a custom view mode for my entity, done with hook_entity_info_alter()):

  function hook_preprocess_taxonomy_term(&amp;$variables) {
  $variables['view_mode'] = $variables['elements']['#view_mode'];
  $variables['term'] = $variables['elements']['#term'];
  $term = $variables['term'];
  $uri = entity_uri('taxonomy_term', $term);
  // Edits are here:
  $variables['term_url'] = url($uri['path'], $uri['options']);
  $variables['term_name'] = check_plain($term-&gt;name);
  $variables['page'] = $variables['view_mode'] == 'full' &amp;&amp; taxonomy_term_is_page($term);
  $variables['term_id'] = drupal_html_id($term-&gt;name);  
  // Flatten the term object's member fields.
  $variables = array_merge((array) $term, $variables);
  // Helpful $content variable for templates.
  $variables['content'] = array();
  foreach (element_children($variables['elements']) as $key) {
    $variables['content'][$key] = $variables['elements'][$key];
  }
  field_attach_preprocess('taxonomy_term', $term, $variables['content'], $variables);

  // Gather classes, and clean up name so there are no underscores.
  $vocabulary_name_css = str_replace('_', '-', $term-&gt;vocabulary_machine_name);
  $variables['classes_array'][] = 'vocabulary-' . $vocabulary_name_css;

  $variables['theme_hook_suggestions'][] = 'taxonomy_term__' . $term-&gt;vocabulary_machine_name;
  $variables['theme_hook_suggestions'][] = 'taxonomy_term__' . $term-&gt;tid;
}


My taxonomy-term.tpl.php:

&lt;div&lt;?php print $attributes; ?&gt;&gt;
  &lt;?php if (!$page &amp;&amp; ($view_mode != 'subcategory_anchor')): ?&gt;
    &lt;h2&gt;&lt;a href="&lt;?php print $term_url; ?&gt;"&gt;&lt;?php print $term_name; ?&gt;&lt;/a&gt;&lt;/h2&gt;
  &lt;?php endif; ?&gt;

  &lt;?php if (!$page &amp;&amp; ($view_mode == 'subcategory_anchor')): ?&gt;
    &lt;h2 id="&lt;?php print $term_id ?&gt;"&gt;&lt;?php print $term_name; ?&gt;&lt;/h2&gt;
  &lt;?php endif; ?&gt;


  &lt;div&lt;?php print $content_attributes; ?&gt;&gt;
    &lt;?php print render($content); ?&gt;
  &lt;/div&gt;
&lt;/div&gt;