Assuming a view with a contextual filter based on a field "category" that is a select list with a limited number of values: what is the best approach to dynamically generate a simple list of links (based on available values) at the top of the view to allow a user to navigate the categories? I want to expose the values as links and keep the clean url structure that contextual filters create. See screen below for reference.

In the past, I've hacked together a basic hard-coded solution using hook_views_pre_render and the l() function, but I'm wondering what the best practice would be.

contextual filter navigation links

1 Answer 1


Take a look at the quicktabs module. It should let you define "tabs" for these filters.

The Quick Tabs module allows you to create blocks of tabbed content, specifically views, blocks, nodes* and other quicktabs*. You can create a block on your site containing multiple tabs with corresponding content. Clicking on the tabs makes the corresponding content display instantly, using jQuery.

Additionaly, there is this in-depth blog post not written by me showing filtering/sorting a complex view + filters page using quicktabs. The left side of this view page has "tabbed" items like what you want in your example. CSS tweaks will make the tabs "look" how you want.

  • + 1 for good useful info (and possibly a better solution that what I've outlined) but it's not quite what I want. I'm looking for a dynamic solution where the values available in the contextual filter field are automatically retrieved and formatted as links that add a filter value to the url.
    – Dave Bruns
    Nov 18, 2013 at 17:34
  • the hooks in views lets you alter stuff -- I would still use Views and QuickTabs; then make an admin form that overrides the filter values. I'm not aware of any solution for dynamic content like you've listed. You could use a content type and rabbit hole and a nodequeue for your filter items; with a hook_views_pre_view() override to be all user-friendly. But all those dependencies made me throw up just now. :D
    – tenken
    Nov 18, 2013 at 19:07
  • :) Thinking about this again today made me wonder about using taxonomy instead of a regular field for categories. Then, getting a list of tags/links would be trivial, I think. But I don't want the link to go a taxonomy display page, I want it to insert a contextual filter to the original view. Taxonomy always frustrates me because I feel like it adds a lot of stuff I don't really want.
    – Dave Bruns
    Nov 19, 2013 at 17:55

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.