Filterable

Summary: Search box for long lists and tables
Version: 2024-04-14
Prerequisites: ExtensionHub
Status: Beta
Maintainer: Petko
License: MIT
Users: (view? / edit)
Discussion: Filterable-Talk?

This extension creates search boxes that allow to instantly filter tables and lists. See examples below.

Installation

This extension requires ExtensionHub.

Place Filterable-2024-04-14.zip in the pmwiki/extensions directory on your server. Optionally you can unzip it.

Alternatively, you can clone the Git repo into pmwiki/extensions with such a command line:
git clone --depth=1 https://github.com/5ko/Filterable.git

Configuration

To enable the extension, navigate to SiteAdmin.ExtensionHub, locate the "Filterable" row and press "Edit". On the new page, check the checkbox "Enable configuration" and near the bottom press "Save".

Only lists and tables with the "filterable" class name, AND with 5 rows/items or more, become filterable.

In the same configuration form, you can change the minimum number of rows or items, and the query selector for the filterable elements.

For example, instead of the default, to process unordered lists with "searchable" class name, and all tables regardless of their class name, that are above the number of items/rows, you can type in the "Query selectors" input field:

  ul.searchable, table

To make filterable the lists on RecentChanges pages (without a %list filterable% wikistyle), in the Hub table on the Filterable row in the drop-down select "New configuration" and press "Edit". In the new page, check "Enable configuration", in the field "Applies to pages" type "*RecentChanges*", and in the "Query selectors" field type "#wikitext ul", then press "Save".

Internationalization

Translations will be included and ship with the recipe, when I find the time to implement it.

The following strings can be translated in an XLPage, for example in French:

  'Filter table' => 'Filtrer la table',
  'Filter list' => 'Filtrer la liste',

Usage

Just add the "filterable" class to lists or tables that need to be filtered. A filter box will appear before the table or list, and typing in it will show rows or lines that contain the typed string (case insensitive).

Web browsers:
* Firefox %list filterable%
* Chrome
* Chromium
* curl
* Dillo
* Edge
* MSIE
* Konqueror
* Lynx
* Midori
* Netscape
* Opera
* real men browse with `telnet`
* Safari
* SeaMonkey
* wget

Web browsers:

  • Firefox
  • Chrome
  • Chromium
  • curl
  • Dillo
  • Edge
  • MSIE
  • Konqueror
  • Lynx
  • Midori
  • Netscape
  • Opera
  • real men browse with `telnet`
  • Safari
  • SeaMonkey
  • wget

Filterable can be combined with $EnableSortable:

|| class="filterable sortable simpletable"
||!   m||!Geographic zone     ||!Highest point     ||!Country  ||
|| 3700||Arctic               ||Gunnbjørn Fjeld    ||Greenland ||
|| 8848||North Temperate Zone ||Mount Everest      ||Nepal     ||
|| 5790||North Tropical Zone  ||Cayambe            ||Ecuador   ||
|| 6768||South Tropical Zone  ||Huáscarán          ||Peru      ||
|| 6960||South Temperate Zone ||Aconcagua          ||Argentina ||
|| 4892||Antarctic            ||Mount Vinson       ||(none)    ||
mGeographic zoneHighest pointCountry
3700ArcticGunnbjørn FjeldGreenland
8848North Temperate ZoneMount EverestNepal
5790North Tropical ZoneCayambeEcuador
6768South Tropical ZoneHuáscaránPeru
6960South Temperate ZoneAconcaguaArgentina
4892AntarcticMount Vinson(none)

For a table, you can specify the columns that should be filtered, with the attribute data-filtercols=0,1 (comma-separated, starting from zero). In this case the other columns will be ignored when filtering.

Filtering only on the second and fourth columns:

|| class="filterable simpletable" data-filtercols=1,3
||!   m||!Geographic zone     ||!Highest point     ||!Country  ||
|| 3700||Arctic               ||Gunnbjørn Fjeld    ||Greenland ||
|| 8848||North Temperate Zone ||Mount Everest      ||Nepal     ||
|| 5790||North Tropical Zone  ||Cayambe            ||Ecuador   ||
|| 6768||South Tropical Zone  ||Huáscarán          ||Peru      ||
|| 6960||South Temperate Zone ||Aconcagua          ||Argentina ||
|| 4892||Antarctic            ||Mount Vinson       ||(none)    ||
mGeographic zoneHighest pointCountry
3700ArcticGunnbjørn FjeldGreenland
8848North Temperate ZoneMount EverestNepal
5790North Tropical ZoneCayambeEcuador
6768South Tropical ZoneHuáscaránPeru
6960South Temperate ZoneAconcaguaArgentina
4892AntarcticMount Vinson(none)

Notes

To do / some day / maybe

If you have future plans or wishes for this recipe.

Change log / Release notes

  • 2024-04-14: Enable filtering for specific columns.
  • 2024-03-02 Update for simpler extGetConfig().
  • 2024-02-24 Replace wikilib.d with wikiplain.d. Add space between searchbox and table. Add README.
  • 2024-02-20 First public release, ready to be tested.

See also

Cookbook /
FoxCSV  Display csv tables automatically or via templates; filtering, sorting, editing csv data. (beta)
TextExtract  search, grep, and extract text from other pages or groups with search terms and regular expressions, using search form or markup expression. (stable)

Contributors

PmWiki extension written and maintained by Petko. Jets.js library by Denis Lukov.

Comments

See discussion at Filterable-Talk?

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.