0

I have a custom view (page) created using Views in Drupal 7.

It contains a taxonomy field and an (exposed) taxonomy filter. When viewing the custom page/view, it works exactly as needed and a user can select a taxonomy filter to limit results accordingly. For example, the default view is /books and the user, via the exposed filter can select /books?book_type[]=21 to show only the books that have taxonomy ID 21.

The problem I am experiencing is that I need a second custom view (essentially a series of thumbnails, each depicting a different 'book_type') to link directly to the /books?book_type[]=21 URL path. Within this second view, I have added the appropriate taxonomy field and via the Rewrite Results option of the field, I have selected Output This Field as a Link and inserted books?book_type[]=[field_book_taxonomy], where [field_book_taxonomy] is the referenced taxonomy field.

When I view this thumbnail page, the link works, but the URL contains the taxonomy name rather than ID. So whilst I need /books?book_type[]=21, the page receives /books?book_type[]=ficton.

I have tried various Contextual Filters, including Term Name converted to ID, but the URL always passes name and the page therefore returns "An illegal choice has been detected".

Ideally I would like to retain the path /books?book_type[]=ficton on the initial view and have this interpreted successfully by the actual filtered view.

Please can someone offer a pointer as to where I am going wrong with this?

Thank you.

1 Answer 1

0

I don't think it is possible to pass term name,instead of term id, as value for exposed filter. But if you are fine with passing term id in your second view then while rewriting the output check the replacement patterns available there you will see the term id.

Like if your field name is field_book_taxonomy then in your replacement patterns you will see two patterns like [field_book_taxonomy] and [field_book_taxonomy-tid], choose the later one.

2
  • Hi. Initially thought -tid was missing, but I was looking at a rendered version of the taxonomy term in the view, rather than the term itself. Thanks for pointing me in the right direction; sending the -tid pattern looks like it will do the trick.
    – MCG
    Commented Jul 9, 2014 at 17:59
  • Indeed it works perfectly, thanks again for the pointer, I appreciate it.
    – MCG
    Commented Jul 9, 2014 at 18:04

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.