DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:struct:filters

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
plugin:struct:filters [2016-08-18 10:01] – [Fixed Filters] andiplugin:struct:filters [2023-11-01 16:06] (current) – [Fixed Filters] andi
Line 13: Line 13:
 <code> <code>
 ---- struct table ---- ---- struct table ----
-schemas  : projects A+schema   : projects A
 cols     : %pageid%, product, budget, team cols     : %pageid%, product, budget, team
 filter   : product = Fantastico Basic filter   : product = Fantastico Basic
Line 20: Line 20:
 </code> </code>
  
-Column names can of course reference the full column name (eg. ''projects.product'') or use defined aliases (eg. ''A.product'').+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. ''projects.foo.bar'').
  
 ===== Comparators ===== ===== Comparators =====
Line 26: Line 26:
 For filtering, multiple comparators are possible: For filtering, multiple comparators are possible:
  
-^ Comparator       ^ Meaning ^ +^ Comparator        ^ Meaning                                                                                                                                                                                                                                          
-| ''=''            | Exact match | +| ''=''             | Exact match                                                                                                                                                                                                                                      
-| ''!='' or ''<>'' | Does not exactly match | +| ''!='' or ''<>''  | Does not exactly match                                                                                                                                                                                                                           
-| ''<''            | Less than | +| ''<''             | Less than                                                                                                                                                                                                                                        
-| ''%%<=%%''       | Less or equal than | +| ''%%<=%%''        | Less or equal than                                                                                                                                                                                                                               
-| ''>''            | Greater than | +| ''>''             | Greater than                                                                                                                                                                                                                                     
-| ''%%>=%%''       | Greater or equal 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. 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''+| ''*~''            | 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. | +| ''!~''            | Negative Wildcard match. Select everything that does not match the expression.                                                                                                                                                                   
-| ''=*''           | Regular expression search |+| ''=*''            | Regular expression search; example: ''keyword =* Hydraulic%%|%%Spindle'' filters out pages where the keyword is "Hydraulics" or "Spindle". \\ \\ To match an empty value use ''=* %%^%%(?![\s\S])''                                              | 
 +| ''IN''            | 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: ''somefield IN ("a", 'b', 123, 12.1)''  |
  
 ===== Value Placeholders ===== ===== Value Placeholders =====
Line 46: Line 47:
 <code> <code>
 ---- struct table ---- ---- struct table ----
-schemas  : projects A+schema   : projects A
 cols     : %pageid%, product, budget, team cols     : %pageid%, product, budget, team
-filter   : team = %USER%+filter   : team = $USER$
 ---- ----
 </code> </code>
  
-^ Placeholder                        ^ Description                                                          +^ Placeholder                        ^ Description                                                                    
-| ''$USER$''                         | currently logged in user                                             +| ''$USER$''                         Currently logged in user                                                       | 
-| ''$TODAY$''                        | Today's date in Y-m-d format                                         +| ''$USER.name$''                    | Real name of currently logged in user                                          | 
-| ''$ID$''                           | The page's full page ID (of the page the aggregation is defined on)  +| ''$USER.email$''                   | Email of currently logged in user                                              | 
-| ''$PAGE$''                         | The page's page name without a namespace                             +| ''$USER.grps$''                    | Groups of currently logged in user. Useful with [[plugin::structgroup]] plugin.
-| ''$NS$''                           | The page's namespace                                                 +| ''$TODAY$''                        | Today's date in Y-m-d format                                                   | 
-| ''$STRUCT.//<schema>.<field>//$''  | The struct data saved for the current page in given field.           |+| ''$DATE(//<formula>//)$''          | A calculated date, where ''//<formula>//'' is a valid [[phpfn>datetime.formats|Date/Time 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 ===== ===== Dynamic Filters =====
  
-Aggregations can be "live" filtered by either adding the ''dynfilters'' option or passing the right URL parameters.+Aggregations can be "live" filtered by either adding the ''dynfilters'' option, using a [[plugin:struct:cloud|Cloud Control]] or [[plugin:struct:aggregation:filter|Filter Control]] or by passing the right URL parameters.
  
 The following example adds filter input fields for all selected columns. The following example adds filter input fields for all selected columns.
Line 68: Line 73:
 <code> <code>
 ---- struct table ---- ---- struct table ----
-schemas    : projects A+schema     : projects A
 cols       : %pageid%, product, budget, team cols       : %pageid%, product, budget, team
 dynfilters : 1 dynfilters : 1
Line 76: Line 81:
 Filters created through this method always use the ''*~'' comparator, eg. look for the search term anywhere in the column's data. 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.+==== 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.
  
 Example: ''?flt[projects.budget>]=10000'' Example: ''?flt[projects.budget>]=10000''
 +
 +For example you could add the above filter to an internal link like this:
 +
 +<code>
 +[[:myprojects:overview?flt[projects.budget>]=10000|Show large Projects]]
 +</code>
 +
 +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.
 +===== Multiple Filters =====
 +
 +If multiple ''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. 
 +
 +<code>
 +---- struct table ----
 +schema: colors
 +cols: *
 +filter: color <> yellow
 +filter: color <> green
 +csv: 0
 +---- 
 +</code>
 +
 +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. 
 +
 +<code>
 +---- 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
 +---- 
 +
 +</code>
 +
 +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. 
 +
  
plugin/struct/filters.1471507302.txt.gz · Last modified: 2016-08-18 10:01 by andi

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