DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:struct:filters

This is an old revision of the document!


Struct Plugin

Struct Plugin: Filters

Filters are used to filter aggregations.

Fixed Filters

Fixed filters are added through the filter and filteror options. They expect a column name, a comparator and a value to compare with.

Example:

---- struct table ----
schemas  : projects A
cols     : %pageid%, product, budget, team
filter   : product = Fantastico Basic
filteror : product = Fantastico Professional
----

Column names can of course reference the full column name (eg. projects.product) or use defined aliases (eg. A.product).

Comparators

For filtering, multiple comparators are possible:

Comparator Meaning
= Exact match
!= or <> Does not exactly match
< Less than
<= Less or equal than
> Greater than
>= Greater or equal than
~ Wildcard match. Use a * as wildcard. Like Apple* to match Apple Pie and Apple Computer; e.g. dessert~ *Pie. Case insensitive.
*~ Wildcard match. Look for matches containing search term; e.g. dessert*~ Pi match Apple Pie
!~ Negative Wildcard match. Select everything that does not match the expression.
=* Regular expression search

Value Placeholders

When defining fixed filters it is sometimes useful to compare against semi-dynamic values. This is where value placeholders come in handy. You simply use the placeholder instead of a value when creating the filter.

The following example prints all projects the current user is a team member of:

---- struct table ----
schemas  : projects A
cols     : %pageid%, product, budget, team
filter   : team = $USER$
----
Placeholder Description
$USER$ currently logged in user
$TODAY$ Today's date in Y-m-d format
$ID$ The page's full page ID (of the page the aggregation is defined on)
$PAGE$ The page's page name without a namespace
$NS$ The page's namespace
$STRUCT.<schema>.<field>$ The struct data saved for the current page in given field.

Dynamic Filters

Aggregations can be “live” filtered by either adding the dynfilters option or passing the right URL parameters.

The following example adds filter input fields for all selected columns.

---- struct table ----
schemas    : projects A
cols       : %pageid%, product, budget, team
dynfilters : 1
----

Filters created through this method always use the *~ comparator, eg. look for the search term anywhere in the column's data.

Dynamic filters can also be added through the flt parameter. The parameter is an array type, with the column name and comparator combined in the key and the comparison value in the value part.

Example: ?flt[projects.budget>]=10000

plugin/struct/filters.1471521304.txt.gz · Last modified: 2016-08-18 13:55 by 130.112.1.3

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki