WikiDB/Repeat tag syntax

From TestWiki
< WikiDB
Revision as of 12:57, 31 March 2019 by HappyDog (Talk | contribs) (Brought up to date and given a general overhaul.)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

See WikiDB/Repeat tag syntax/Archive for old development discussion.

The <repeat> tag allows you to query the data.

<repeat table="..." criteria="..." sort="...">Any old wiki text, with {{{variable}}} substitution.</repeat>

The tag recognises the following attributes:

table (required)
This defines where the data comes from. The table does not need to be defined on the wiki - the tag will pull data for all rows that specified this table, even if the table does not exist.
criteria (optional)
Specifying this allows you to restrict the set of records that are displayed. If no criteria is specified, all rows are included.
sort (optional)
The rows are sorted by the fields in the order specified. If no sort is specified, then the sort order is undefined and may vary between page views.

Full syntax for the criteria and sort attributes is the same as is used on the 'viewdata' tab to live-filter the data. See WikiDB/Querying data for full details. Note that, in the context of an HTML attribute, the < character is not allowed, therefore you should use LT and LTE instead of < and <= in this context.

Controlling the rendering[edit]

There are currently two ways for the results of the query to be rendered:

  • If the repeat tag is empty (or just contains white-space) then WikiDB will output the data as a table, in a standard format.
  • If the repeat tag contains any text, then this will be repeated for each row returned by the query. Any field name inside three curly brackets (e.g. {{{FieldName}}}) will be replaced by the value of the field for the current row, and the result will be parsed as wiki text. Field aliases are resolved correctly, so if you defined 'name' as an alias for 'first name' then using either field will give the same result.

Headers and footers[edit]

It is possible to specify a header and/or footer section within your repeat tag, and if present these are output before/after the individual rows. For most use-cases you could achieve the same result by putting the header/footer content outside the tag, but due to the way MediaWiki rendering works it is not possible to do this if you want to output a table. To output a custom table, you will need to open it in your header section and close it in your footer, like this:

<repeat Table="Companies3">
{| class="wikitable"
! Name !! Revenue
| '''{{{Name}}}''' <small>{{{Location}}}</small> || {{{Revenue|Unknown}}}<br>

Name Revenue
Microsof Seattle $8
Apple $7.42
Intel Unknown