I need to create functionality so that the user can switch between different sort/filter behaviors in a view. Hopefully, without loading a different page.

For example, I have a list of projects on my site and I want buttons that the user can click to hide projects that aren't of a specific type. ie: show only print, show only web, show only video, etc.

Is there any way to do this asynchronously with views, rather than custom scripting stuff with jquery or linking to totally different pages?


You can set your filters and sorts to be exposed, which means the end user can interact with them choosing how to sort or filter the results,

There is also a setting in the "Advanced" column on the right of the views admin page called "Use AJAX". Set that to "Yes" and you will no longer have to have page loads when the user changes filters and sorts.

Note: If your view is a block view, you must turn on ajax for exposed filters to work.

Also, in the "Advanced" column if you click the "Settings" link for the "Exposed form style" option. In there you can check the "Autosubmit" checkbox, which will mean the view will be reloaded when the user selects a filter, without them having to click submit. This may or may not be desirable depending on your use case.

One last thing is the "Exposed form in block" setting. If you set that to "Yes" then a block will be available that will contain the filter and sort settings, so you can put them wherever you want, instead of them having to be in the top of the view.

Note: You cannot use exposed form in block with a block view. A potential workaround (I have not actually tried it) is here - https://drupal.stackexchange.com/a/38994/10729

  • Thanks a lot! That was exactly what I was looking for. (I overlooked the expose filter checkbox whenever I created a new filter) I have a new problem though. The "Exposed form in block" setting isn't available under "EXPOSED FORM", I can only change settings for exposed form style. Any idea how I can get that exposed form in block setting back or if there's a module I need to download in order to do it? Thanks again! – architarious Apr 24 '13 at 18:19
  • Is your views display a block view? Block views can't use exposed filters in a block because in that case the exposed filter block and the views block can't talk to each other. It either has to be exposed filters in a block for a page view or exposed filters not in a separate block. I also added to my question a note to say you have to enable ajax to use exposed filters in a block. There is a work-around for exposed filters in a block and your view in a block that apparently works but I haven't tried it. See here - drupal.stackexchange.com/a/38994/10729 – rooby Apr 25 '13 at 1:19

I am assuming here that you want the user to switch between a number of different views. If that be the case you can try out the Quicktabs module. You can then create different views and have them presented as tabs. Quicktabs allows you to switch between the tabs using ajax.

  • Thanks, I was trying to avoid using multiple view nodes, but this will be helpful on other projects! – architarious Apr 24 '13 at 18:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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