History: Sublist
Source of version: 8
Copy to clipboard
! 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: [https://fosdem.org/2024/schedule/event/fosdem-2024-3484-pushing-tiki-to-its-limits/|FOSDEM 2024] __Related Merge request__: [https://gitlab.com/tikiwiki/tiki/-/merge_requests/4353|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__: # Create a tracker called __Region__ with ID, Name as fields # Create an other tracker called __Hospital__ with ID, Name and Region (Item Link pointing to region tracker) # Fill all trackers with data as well # Apply this code: {CODE()} !!! 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} {CODE} 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). __Not that__ underlying implementation makes sure to execute only one query for all the records found in the parent list block and then distributed 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 ): {img src="display2015" link="display2015" width="400" rel="box[g]" imalign="center" desc="Click to expand" align="center" styleimage="border"} !! Related See also: * ((PluginTrackerList)) * ((PluginTrackerList To PluginList Converter)) * ((PluginTracker)) * ((PluginList))