3.5.2. Views exposed filters. Drupal: Ads board
The Views module allows you to not only set a filter and display materials, but also allows you to change these filters dynamically. Let's create a small real estate bulletin board using the Views module.
In order to display ads, we first need to create an announcement content type. To do this, go to Structure - Content types - Add Content type:
Now for our content type you need to add the fields: Number of rooms, price, address, phone, name. We go to the tab Manage fields of the content type Announcement:
For the number of rooms you need to select the type List (text):
Next you need to set what types of apartments are:
You also need to add a Price, for this, select the field type Number (integer). In the Settings for the Prices field, specify the prefix so that the name of the currency comes after the price:
The fields address, telephone and name can be created with the type Text (plain).
Now that we have the fields, let's create a new view of the Announcement (Structure - Views — Add view):
Now let's add the Number of rooms filter and put this checkmark for exposed filters:
This will allow you to display this filter on the Announcement page:
Now if we choose any of the parameters, there will be only one type of apartment:
You can also add any other fields to the Announcement and display them as Exposed filters. Let's add the price to exposed filters as well.
When we set the Between operator, we allowed the user to set the price range that suits him.
In addition to exposed filters, we can also perform sorting, for example, by price, allowing users to select sorting in descending order of price or ascending order:
Now we have a filter for announcement, which really remains to be themed.