Table of Contents
Struct Plugin: Filters
Filters are used to filter aggregations.
Fixed filters are added through the
filteror options. They expect a column name, a comparator and a value to compare with.
---- struct table ---- schema : 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). Should your field name contain a dot, you always need to provide a full column name (eg.
For filtering, multiple comparators are possible:
| ||Exact match|
| ||Does not exactly match|
| ||Less than|
| ||Less or equal than|
| ||Greater than|
| ||Greater or equal than|
| || Wildcard match. Use a
| || Wildcard match. Look for matches containing search term; e.g.
| ||Negative Wildcard match. Select everything that does not match the expression.|
| || Regular expression search; example:
To match an empty value use
| || Match any element in a list. List is limited by round brackets and contains elements separated by comas. Each element can be a string (limited by single or double quotes) or a number. Example syntax:
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 ---- schema : projects A cols : %pageid%, product, budget, team filter : team = $USER$ ----
| ||Currently logged in user|
| ||Real name of currently logged in user|
| ||Email of currently logged in user|
| ||Groups of currently logged in user. Useful with structgroup plugin.|
| ||Today's date in Y-m-d format|
| || A calculated date, where
| ||The page's full page ID (of the page the aggregation is defined on)|
| ||The page's page name without a namespace|
| ||The page's namespace|
| ||The struct data saved for the current page in given field.|
The following example adds filter input fields for all selected columns.
---- struct table ---- schema : 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.
Manually Creating Filter Links
Dynamic filters can also be added through the
flt parameter. The parameter is an array type, with the schema name, column name and comparator combined in the key and the comparison value in the value part.
For example you could add the above filter to an internal link like this:
[[:myprojects:overview?flt[projects.budget>]=10000|Show large Projects]]
When following that link, an aggregation on that page
myprojects:overview will be dynamically filtered to all projects with a budget greater than 10000. A filtering note and a link to reset the filtering is displayed above the aggregation.
filter: instructions are used, all conditions must be true, comparable to the AND operator in SQL.
The following example removes all results with the color yellow or green from the result set.
---- struct table ---- schema: colors cols: * filter: color <> yellow filter: color <> green csv: 0 ----
To combine multiple filters where it is sufficient for any of the conditions to be true, comparable to the OR operator in SQL, you can either work with
filteror: instructions or with the
IN comparator, also present in SQL.
The following two examples are identical and will only show results where the color is either yellow or green.
---- struct table ---- schema: colors cols: * filteror: color = yellow filteror: color = green csv: 0 ---- ---- struct table ---- schema: colors cols: * filter: color IN ("yellow","green") csv: 0 ----
Note that the struct plugin currently has no support for the
NOT operator present in SQL. For example, it's currently not possible to create a filter with a
NOT IN comparator.