Loading...
 
Skip to main content

History: Sublist

Preview of version: 9

PluginList sublist

New in Tiki27, permitting to improve PluginList, and fixes/enhancements are being backported to the Tiki26 branch. Once it is more stable/robust, it may also be backported to Tiki24.

This was one of the recommendations from this large project: FOSDEM 2024

Related Merge request: PluginList SUBLIST MR

Example Usage

PluginList SUBLIST gives the ability to join several trackers and get mixed results into a single array, greatly optimizing the performance when subqueries and sub-list plugins are needed.
Steps to follow:

  1. Create a tracker called Region with ID, Name as fields
  2. Create an other tracker called Hospital with ID, Name and Region (Item Link pointing to region tracker)
  3. Fill all trackers with data as well
  4. Apply this code:
Copy to clipboard
!!! Stock table template {LIST()} {filter type="trackeritem"} {filter field="tracker_id" exact="1"} {SUBLIST(name="region")} {filter field="tracker_id" exact="2"} {filter field="object_id" exact="$parent.tracker_field_hospitalRegion$"} {FORMAT(name="name")}{display name="tracker_field_regionName" default=""}{FORMAT} {SUBLIST} {OUTPUT(template="table")} {column field="hospital" label="Hospital" mode="raw"} {column field="region" label="Region" mode="raw"} {OUTPUT} {FORMAT(name="hospital")}{display name="tracker_field_hospitalName" default="" }{FORMAT} {FORMAT(name="region")}{display name="region.name" default=""}{FORMAT} {LIST}

First List Plugin joins tracker 1 (tracker hospital) and tracker 2 (tracker region) with an Item Link field in tracker 1 (tracker hospital) pointing to tracker 2 (tracker region) called tracker_field_hospitalRegion....Sublist filters the results by the ID of the record coming from the parent tracker(here tracker region).
Note: The underlying implementation makes sure to execute only one query for all the records found in the parent list block and then distributes the results to the relevant resultset rows.
Output template is using the stock table template with wiki formatting the name field of tracker 2 (tracker region) and then wiki formatting the table column for region name using nested keys like 'region.name'.
Region is the key name in SUBLIST block, so it adds an array of records in the parent row under the 'region' key. Then, it formats and adds the tracker 2 (tracker region) field(s) to that key for each parent record.
The given above code in step 4, would produce (accordingly to the data filled in trackers...step 3 ):

Click to expand
Click to expand

See also:

History

Advanced
Information Version
Bernard Sfez / Tiki Specialist 17
Jean-Marc Libs 16
luciash d' being 🧙 separate the notes a bit 15
Baraka Kinywa Trackers order creation, Tracker Region id 1 and Tracker Hospital id 2 14
Jean-Marc KADIMBA 13
Jean-Marc KADIMBA The tracker Region must be the tracker 1 and Hospital the tracker 2, because Region is created before Hospital. In the SUBLIST we use the tracker Region (Tracker 1) 12
Jean-Marc KADIMBA The tracker Region must be the tracker 1 and Hospital the tracker 2, because Region is created before Hospital 11
Baraka Kinywa 10
Marc Laporte Cosmetic 9
Baraka Kinywa 8
Baraka Kinywa 7
Marc Laporte 6
Baraka Kinywa 5
Marc Laporte 4
Marc Laporte 3
Marc Laporte 2
Marc Laporte 1