====== Strata Practical Examples ====== ===== Page purpose and status ===== This page provides practical examples for the [[plugin:strata|Strata plugin]]. It is a working draft document. ====== Basic queries ====== The examples in this section are based on the following three pages existing: '':data:cities:madrid'' ====== Madrid ====== ---------- metro_area: Madrid metropolitan area country: Spain population: 3141991 mayor: Manuela Carmena ---------- '':data:cities:london'' ====== London ====== ---------- metro_area: Greater London country: UK population: 8673713 ---------- '':data:cities:berlin'' ====== Berlin ====== ---------- metro_area: Berlin-Brandenburg Metropolitan Region country: Germany population: 3670622 ---------- ===== City name (with link to article) and population ===== List all cities and their population in a table. Columns: - **Name**. Hyperlink to page on which the city data is defined. - **Population**. Text field. Displays population. ==== Strata code ==== fields { -- Each field becomes a column in the displayed table ?name: Name ?pop: Population } -- The result set will contain one row for each city data object found by the query -- The first column contains a link to the page on which that data object code is found ?name is a: city ?name Population: ?pop
=== Fields === Columns are defined inside ''fields'': - ''?name: Name'' assigns the caption ''Name'' to the ?name field''. ?name is a: city'' defines ''?name'' as a city data object. In this example, the city data objects exist on each city's page. Strata assigns a link to that page to ''?name''. Now, ''?name'' can be used to link other fields to this result row. - ''?pop:Population'' defines the id and description of the second column. ''?name Population: ?pop'' tells Strata to populate the second column with the value of the Population field in the city data object. ==== Expected output ==== ^Name^Population^ |Berlin|3670622| |London|8673713| |Madrid|3141991| ===== Cities with fewer than 5 million inhabitants ===== fields { ?name: Name ?pop: Population } ?name is a: city ?name Population: ?pop ?pop < 500000
====== ui block: User Interface ====== ===== Tables: field filtering ===== The UI block affects the way in which the results are presented to the user: * Cosmetic affects * Field filtering: filter one or more columns of a table using dropdowns or free-text filtering ==== Strata code ==== fields { ?name: Name ?pop: Population } ?name is a: city ?name Population: ?pop ui { -- Adding * allows multiple values filter*: select, text }
==== Expected output ==== {{http://i.imgur.com/UUJ2ANc.png}} ==== Behaviour ==== * All non-blank filters must match the row under consideration, or it will not be displayed * Numbers are treated as text by the table filters * When specifying filter type, it is possible to specify one of: * ''filter:'' takes a single filter type shared by all columns * ''filter*:'' takes one filter type per column; comma-separated; number of arguments must match number of columns ====== Interaction with other plugins ====== FIXME ====== Examples FAQ ====== ===== Why don't numeric operators seem to affect query results? ===== Numeric operators require that any field value resemble only an integer or a float. For example, Strata will numerically compare ''56'' or ''387.2874'', but will treat ''5,320,000'' as a string. Strata uses the comma '','' to separate multiple values on a single line. So if we wanted to store multiple numbers be definitely couldn't use the human-readable separates. For example, value ''3,455, 6,777'' is completely ambiguous. In any case, the Decimal Mark Standard suggests that representations of larger numbers should not use commas to group digits into threes for readability . In summary, when storing numbers in Strata, use only 0-9 and your locale-specific decimal separator ''.'' or '',''. ===== What do the ---- in the data examples do? ===== No functional effect. They are comments intended to make the data section stand out on a real-world page with lots of content.