Making a view with exposed filters

Benjamin Melançon's picture
Submitted by Benjamin Melançon on 2010, August 11 - 16:42
  • A View with exposed filters begins like any other View: Administer » Structure » Views, Add new view (admin/structure/views/add). View name, suggestions (remember this is akin to the machine name), View description, Suggestions (this is the name used on Views administration pages), and View type, Node.

    Next page, the real View configuration.

    Under Style settings (fourth block down in the first row) we click on Fields in order to change the Row style to Node. Update, keep Build mode as Teaser, and Update the last time.

    Add Filters (fourth and last block in the third and last column), filter the filters by Groups for Node then checkmark Node: Published and Node: Type. Click Add, and then we get to choose Published Yes (click Update) and Operator Is one of Node type Suggestion.

    We'll keep this as our base View and add the exposed filters to our page display. A good old-fashioned paranoia save of the View can't hurt.

    After adding the Page display, we need to click on it to start configuring it. (After adding it we remain on the Default, base, configuration.)

    Page: The menu path or URL of this view
    http://definitivedrupal.org/ suggestions

    We do Taxonomy Term ID, not name. The Views administrative UI will show us the name, but the internal filtering will be done with the more efficient ID.

    Page: Configure extra settings for filter Taxonomy: Term
    Vocabulary
    Book elements
    Index
    Response type
    Status
    Tags
    Timeline tag

    Select which vocabulary to show terms for in the regular options.
    Selection type
    Dropdown
    Autocomplete

    Leave Operator at Is one of

    We don't have to select any terms because we will be exposing this selection.

    And click Expose.

    We have to go back and edit the filter to customize the expose options.

    Optional
    This exposed filter is optional and will have added options to allow it not to be set.
    Force single
    Force this exposed filter to accept only one option.

    provides the cleanest looking interface.

    We change the Label from Taxonomy: Term to Suggestion type

    Now we do the exact same steps to add filtering for an additional vocabulary, this time for the state of readiness in the book.

    Vocabulary Status
    Selection type Dropdown

    Update.

    Click Expose. Again, we have to go back and edit the filter to change the exposed filter options. We click on the second "Taxonomy: Term" now listed under Filters to do that.

    We make the Filter identifier status_id and the Label Status.

  • Book element

  • How to