Filters are used to specify selection criteria to select required records from a table. Therefore, using filters in views can help us reduce the result set to the required amount of data. We can add multiple filter criteria. In Drupal 6, all the filters are ANDed together, but in Drupal 7, we have the option to add the criteria as AND and OR.
- Create a view
- Then click on the "Add" button.
- A list of filters will be available. For eg. "Content: Type", "Content: Has taxonomy term", "Content: Post Date", etc. Select any filter criteria as per your requirement.
- Add other options related to those criteria. Each criterion contains different options (according to the content).
- Exposed filters are displayed to the user. Users can control the filter and modify the result set. In Drupal 7, we have the option to choose between “single filter” and “grouped filter”. You can expose any filter.
We can create advanced search using views filter in views. Let us create a Job search functionality using views.
- Create a content type with the following fields.
- Job Title
- Job Description
- Job Category
- Experience Required
- Minimum Salary Expectation
- Maximum Salary Expectation
- Location
- Skills Required
- Designation
2. Add few contents of the type Job
3. Create a view with the following information.
- Title: Search
- Format: Format – Unformatted list, Show – Content|Teaser
- Fields: The content format does not utilize fields. Select Show: Fields if you want to add fields.
- Filter Criteria: Add the following filters with OR operator.
- Content Type: Is one of Job (= Job)
- Content Published (Yes)
- Taxonomy Term: Job Category: Expose
- Content: Location: Expose
- Content: Location: Expose
- Content: Experience: Expose
4. Sort Criteria: Content: Post date (desc)
5. Path: /job-search
6. Save the view and check the view on the page sitename/job-search