Drupal モジュール Better Exposed Filters の導入から使用例まで

Drupalの Better Exposed Filters モジュール使用例です。

The Better Exposed Filters module replaces the Views’ default single- or multi-select boxes with radio buttons or checkboxes, respectively. Description fields and Select All/None links can be added to exposed filters to make for a better user experience.
Better Exposed Filters | Drupal.org

Better Exposed Filters


$ cd /var/www/d7dev/
$ sudo drush dl devel
$ drush en devel devel_generate

Home » Administration » Configuration » Development – Generate content
Content type ->すべてにチェック
How many nodes would you like to generate? -> 50
Maximum number of comments per node. -> 5
Add an url alias for each node. -> tick
Generate 押下

■Better exposed filters

・Better exposed filtersモジュールおよび関連モジュールインストール
$ cd /var/www/d7dev/
$ sudo drush dl views ctools better_exposed_filters
$ drush en views views_ui ctools better_exposed_filters
$ drush pm-list –type=Module –status=enabled

Home » Administration » Structure -> Views -> Add new view
View name: filtersTest
Display format : Table
Create a menu link : tick, Main menu

– Fields
Add -> Content: Body, Content: Image, Content: Type
Content: Body (Body) -> Rewrite results -> Trim this field to a maximum length: tick, Maximum length : 255
Configure field: Content: Image -> Image style: Thumbnail

– Filter criteria
Add -> Content: Title, Content: Type
Configure filter criterion: Content: Title
Expose this filter to visitors, to allow them to change it : tick
Operator -> Contains
Configure filter criterion: Content: Type
Expose this filter to visitors, to allow them to change it : tick
Allow multiple selections : tick

– Advanced
Exposed form style: Basic -> Better Exposed Filters
Page: Exposed form options
Autosubmit : tick
Display “type” (Filter label: “Type”) exposed filter as : Checkboxes/Radio Buttons
More options for “type” (Filter label: “Type”) -> Add select all/none links : tick
More options for “type” (Filter label: “Type”) -> Make this filter collapsible : tick