This is an old revision of the document!
Table of Contents
Struct Plugin: Aggregation
Table
Aggregation of structured data is the main purpose of the plugin. Aggregation is done through a simple syntax which will result in a dynamic table listing all data matching certain criteria.
The basic syntax looks like this:
---- struct table ---- schema: schema_name cols: %pageid%, other, cols ----
The aggregation syntax is very similar to that of the data plugin. The main difference is that you have to specify a schema name (or more than one).
The keyword before the colon is a configuration option and the value after it is the actual setting. To make it more fault tolerant, multiple option names are frequently possible. Here is a list of all available options:
Option(s) | Required? | Description |
---|---|---|
schema from | yes | These are the schemas from which you want to display the data. |
cols select | yes | These are the attributes you want to display. These are the same names you used in the Data Entry part. You may use * to select all columns. This can be combined with Special Names e.g. %pageid%, * |
head header headers | no | If specified, these names will be used in the table headers instead of the column names |
max limit | no | How many rows should be displayed. If more rows are available the table will be made browsable. If not given all matching rows are shown |
sort order | no | By what column should the table be sorted initially? Prepend a ^ to reverse the sorting |
filter where filterand and | no | Filter by a column value. You may specify this more than once, multiple filters will be ANDed. (see also filters) |
filteror or | no | Like filter, but multiple instances will be ORed (see also filters) |
dynfilters | no | Set to 1 to enable a row of input fields for dynamically filtering the table |
summarize | no | Set to 1 to calculate sum of columns |
align | no | List of column alignments. The alignments can be left (l ), center (c ) or right (r ) |
rownumbers | no | Set to 1 to show row numbers |
width widths | no | Comma-separated list of column widths to use. CSS units and percentages can be given |
csv | no | Set to 0 to disable the CSV export for this aggregation |
Please note that you can join data from multiple schemas as long as they reference the same pages. This is of course not possible with aggregations of global data.
Aliases
When selecting data from multiple schemas which contain the same field names, you have to prefix them with the schema name:
---- struct table ---- schema: schema1, schema2 cols: %pageid%, schema1.name, schema2.name ----
You can use aliases as shortcodes to reference schemas in order to reduce your typing. Aliases are separated by a space from the schema name:
---- struct table ---- schema: schema1 A, schema2 B cols: %pageid%, A.name, B.name ----
Please see filters to learn more about filtering.
Special Columns
The following special column names can be used to access non-field columns:
Special Name | Description |
---|---|
%pageid% | The page name of the page holding the matching struct data, if any |
%title% | The title (first heading) of the above page |
%rowid% | The number of the row in the database (meaningful only for global and serial data) |
%lastupdate% | The date and time when the page or data was last updated |
%lasteditor% | The user that last changed the page |
%lastsummary% | The last edit summary of the page |
List
As an alternative to the table, you can also aggregate the data in list form. This is largely analogous to Data Lists of the data-plugins
The basic syntax for list aggregations is very similar to table aggregations and looks like this:
---- struct list ---- schema: schema_name cols: %pageid%, other, cols ----
Lists support a new option: sepbyheaders
. If you set this option to 1
and define headers for the columns, than each column will be prefaced with their header.
Several options from the table-aggregation are not supported for the list-aggregation:
Option | supported for lists |
---|---|
schema from | yes |
cols select | yes |
head header headers | with sepbyheaders option |
max limit | yes |
sort order | yes |
filter where filterand and | yes |
filteror or | yes |
dynfilters | no |
summarize | no |
align | no |
rownumbers | no |
width widths | no |
csv | no |
Value
You can include a single value from struct data in the current page with the following syntax:
{{$schema_name.column_name}}
You can also get a value from a different page with:
{{$page_name.schema_name.column_name}}
If you need to add punctuation characters or spacing to any of the names, enclose that part in double quotes:
{{$"namespace:page_name"."schema-name"."column name"}}
You can add filters to the query in much the same way as with the table and list aggregations, but in the following formats, always starting with a question mark. The two forms below, using words followed by colons or symbols without colons, are equivalent:
{{$schema.column ? filter: "product = Fantastico Basic" and: "..." or: "..."}} {{$schema.column ? & "product = Fantastico Basic" & "..." | "..."}}
The filters must be placed in double quotes if they contain spaces, and there must be no space between a filter word and its colon. Extra spaces (such as those used in the example to line up the two formats) are ignored.