Row Filtering Extension 1.3
Thanks for your interest in the Row Filtering Extension!
This is a Premium Extension for TablePress. You may download it without donating and can use without any restrictions.
At the same time, donations are highly appreciated and allow me to continue support and development of this free software.
Please choose what the Extension is worth to you:
If you want, you can then donate via PayPal. Thank you!
For sites that need to show many “small” tables with the same structure, e.g. entries from an inventory database, it can be beneficial to keep all rows in one “big” table, to simplify maintaining and editing the data. While the existing
show_rows Shortcode parameters in TablePress allow showing only a subset of all table rows, this approach can be cumbersome, as the numbers of the table rows need to remain the same.
Instead, an approach similar to a database select query can help, so that only rows with a certain keyword in a column are shown, instead of the full table. That’s the use case for which the Row Filtering Extension can be used. It adds another parameter
filter to the Shortcode that gets passed one or more search terms.
To use this, download, install, and activate the Extension like a regular WordPress plugin. Then, on the page where you want to show the table, insert the extended Shortcode
[table id=1 filter="filter-word" /]
and change the
123 to the desired table ID.
Examples and Logic operators
The standard case likely is filtering for a single word, i.e.
[table id=1 filter="filter-word" /]
Instead of showing all rows, the resulting table will only contain rows that have the search term
filter-word (no matter if upper- or lower-case) in the content of at least one cell.
Using logic operators,
|| (for “or”) and
&& (for “and”), it is possible to search for multiple filter terms.
Thus, a Shortcode like
[table id=1 filter="word1||word2" /]
will show a table that only contains rows that contain
word2 or both in the content of their cells. You can combine as many search terms with
|| as needed.
Similarly, a Shortcode like
[table id=1 filter="word1&&word2&&word3" /]
will show a table that only contains rows that contain all filter terms,
word3 in this example, in the content of their cells. You can combine as many search terms with
&& as needed.
Important note: For technical reasons, mixing the logic operators is not possible though, i.e.
[table id=1 filter="word1||word2&&word3" /]
is not supported.
Additional Shortcode parameters
The filtering of rows can be further controlled using additional parameters in the Shortcode. The parameter
filter_columns allows to define which columns of the table are search for the filter words (all columns by default). For example, the Shortcode
[table id=1 filter="filter-word" filter_columns="3,6-8" /]
would only take columns 3, 6, 7, and 8 into account for searching the filter term
filter-word. If that word were to appear in any of the other columns of the table, those findings would not affect the filtering result.
By default, case sensitivity does not matter, so that both upper- and lower-case matches would be found. To only search for the exact spelling, the parameter
filter_case_sensitive can be used. Thus, a Shortcode like
[table id=1 filter="filter-word" filter_case_sensitive=true /]
would turn on case sensitive filtering.
Furthermore, the default behavior of the Extension is to search for the filter terms anywhere in the cells. This could mean that e.g. the word
car is found in a cell with the text
shopping cart. Therefore, for some applications, it might make sense to only search the full cell content for matches. That can be turned on with the Shortcode parameter
filter_full_cell_match, e.g. in a Shortcode like
[table id=1 filter="filter-word" filter_full_cell_match=true /]
In addition, it is possible to invert the “show matching rows” behavior into a “hide matching rows” behavior, which is possible using the Shortcode parameter
filter_inverse. For example, a Shortcode like
[table id=1 filter="filter-word" filter_inverse=true /]
would show a table that only contains those rows from the table that do NOT contain the filter term
Note that the described Shortcode parameters can be combined as well. As an example, the extended Shortcode
[table id=1 filter="word1&&word2" filter_columns="1-4" filter_case_sensitive=true filter_full_cell_match=true filter_inverse=true /]
would show a table that contains both
word2 in the content of columns 1 through 4, with case-sensitive filtering and full-cell matching turned on.