Submitted by admin on Fri, 09/06/2019 - 17:07

With views, it’s easy to create a restricted listing of content. What’s more, you can also expose those filters to the user, so they can sort and filter the content themselves. Here’s an example of the type of functionality you can enable with “exposed filters”:

Image removed.

So here’s how you set up a simple exposed filter, using Views 3 in Drupal 7:

1. Make sure views is installed, and enabled, and that you're looking at the admin screen of the view you are interested in.

Image removed.

2. Create the filter criteria that we want our users to be able to control, by clicking the "Add" button, in the filter criteria box.

Image removed.

3. I want to expose a filter that allows users to choose which content types are listed, so for my filter criteria, I'll check Content: Type, and click "Apply".

Image removed.

4. On the next screen, check the option "Expose this filter to visitors, to allow them to change it. There are lots of other options, but I'll just leave it at the defaults and click "Apply".

Image removed.

5. Now you can scroll to the bottom of your views admin page and click "Preview" to see a demo of the functionality. Use the select box under "Type" to choose the content type, and click "Apply" to repopulate the view. It works!

Image removed.

6. We can click Save, to save the view, and browse to the path we defined ("/my-new-view"), to see it on the site.

Image removed.

And that’s it! This is the foundation for all kinds of user defined filtering that you can set up. Go forth and build!

Solutions Img