I have a taxonomy reference link appearing on a content type. I have a view showing all nodes tagged with certain terms in that taxonomy vocabulary.

On the view page I configured an exposed filter (select box), with options to filter the view by taxonomy term.

When I use the exposed filter I get a url like in following example: ../viewpagepath?tid=5

When I manually type a different 'tid' as url parameter the active filter option in the exposed filter changes to the corresponding term name.

I used the Taxonomy display module to change the Taxonomy page to the same view. However, when I click on the taxonomy reference link on the content type, I can't get the url to look like this ../viewpagepath?tid=5 so that the right filter option is active.

How do I do this?

I see 2 options:

  1. Changing the term reference link on the content type, so I get the same url pattern. (I can't use Pathauto because it doesn't accept a '?' in the pattern).

  2. Changing the exposed filter url to match a pattern set in pathauto.

Wich one is best? Wich hooks or configuration do I use to get the right result?

1 Answer 1


I've solved a similar problem with drupal_get_path_alias() and hook_form_alter(). In my case I link from my content-type to the taxonomy page with the following:

// have a field with tags - in my content-type template I do
$terms = array();
foreach ($node->field_blog_post_tags['und'] as $key => $value) {
    $terms[] = '<a href="' . $base_url . '/' . drupal_get_path_alias('taxonomy/term/' . $value['tid']) . '">' . $value['taxonomy_term']->name . '</a>';
print implode(', ', $terms);

And to set the exposed filter I use hook_form_alter() in a custom module:

 * Implements hook_form_alter().
function YOUR_MODULE_form_alter(&$form, &$form_state, $form_id) {
  if ('views_exposed_form' == $form_id) {
    // term-id and vocabulary are part of arguments
    $args = func_get_args();
    // select your filter
    if (isset($args[0]->vocabulary_machine_name) && 'YOUR_VOCABULARY' == $args[0]->vocabulary_machine_name) {
      // set the exposed filter with name 'YOUR_FILTER'
      $form_state['input']['YOUR_FILTER'] = $args[0]->tid;

Maybe it's helpful for you.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.