Loading...
 
Skip to main content

History: PluginList output control block

Source of version: 93

Copy to clipboard
            !PluginList output control block

The OUTPUT control block defines what the output 'template' will be for the results.

!!Parameters
{FANCYTABLE(head="parameter | value | example | since")}
downloadable |''filename.csv''	| -+downloadable="MyData.csv"+-	| 18.0
downloadable-position | ''top/bottom/both'' | -+downloadable-position="both"+-	| 25.0
inline	|?	|n/a 		|
report		|''y/n'' 	| 	|20.0? (future)
template	|''file.tpl'' or ''built-in template'' (see below)| ''my.tpl''%%% -+path/to/template/file/my.tpl+-	|
tplwiki		|''wiki page'' (parsed the same as Smarty tpl)	| -+tplwiki="MyTPL"+-				|
wiki		|''wiki page'' (parsed including wiki syntax)	| -+wiki="MyTPL"+-					|
{FANCYTABLE}
!!Built-in templates
{FANCYTABLE(head="name	|purpose									|since")}
carousel				|display the data in a carousel (slider)	|14.0
count					|just count the number of results			|15.0
medialist				|											|13.0
table					|display the data in a table format			|
debug					|display all available data for debugging purposes	|
{FANCYTABLE}

Below the simple Wiki Formatting Within Plugin is discussed as well as the standard/built-in templates, e.g., table, medialist and carousel. For user defined wiki or smarty templates see ((PluginList advanced output control block)).
{maketoc}
!!Basic Wiki Formatting Within Plugin
By placing Wiki syntax directly in the OUTPUT body content, along with the required objects to be displayed, the control block allows a template for each row of output to be constructed within the LIST plugin itself.

In the example below a table is constructed with the table 'header' row placed before the LIST and the table closing characters placed after the LIST. Each row of the table is then created by the LIST plugin with each table cell element generated by the display control block and separated by the usual table separator, i.e., a -+|+-

{CODE(caption="Wiki Output Sample" colors="tiki")}||Type|Object
{LIST()}
{list max="10"}
    {OUTPUT()}{display name="object_type"}|{display name="object_id"}
    {OUTPUT}
    {ALTERNATE()}This will display if no results are found{ALTERNATE}
{LIST}
||
{CODE}

||Type|Object
{LIST()}
{list max="10"}
    {OUTPUT()}{display name="object_type"}|{display name="object_id"}
    {OUTPUT}
    {ALTERNATE()}This will display if no results are found{ALTERNATE}
{LIST}
||

!!Table Formatting
A simple built-in templating method can be used by setting the OUTPUT template parameter to -+table+- and then using a column control block in the OUTPUT body content to define the individual columns of the table.

!!! Table Column Control
!!!! Column Parameters
{FANCYTABLE(name	|value							|since	)}
editable		|''inline''						|11.0
field			|tracker field (permanent name) or FORMAT name reference	|
label			|text							|
mode			|''raw''						|
sort			|tracker field (permanent name) or FORMAT name reference	|
translatelabel		|''y/n''						|18.0
class			| text							| 21.0
{FANCYTABLE}

!!!! Column Mode Parameter
When you use table output with a column generating HTML output (like -+objectlink+- and -+trackerrender+- formatted values), you should include the -+mode="raw"+- in the column specification. In the sample below, the column "title" mode is set to __raw__ as in the format we want to display an __objectlink__. ''Other formats are available; see more about it here: ((PluginList display control block))''

!!!! Format parameters
Added in Tiki 11+ -+editable=inline+- will set the field to be editable inline.
__Required__: "Inline editing (found in trackers)", format="tracker render" and column should be set to -+mode=raw+-.


{CODE(caption="Sample using the default table formatting" colors="tiki")}
{LIST()}
{pagination max="12"}
{filter field="tracker_id" content="17"}
{filter type="trackeritem"}
{OUTPUT(template="table")}
  {column sort="title" label="Title" translatelabel="y" field="title_link" mode="raw"}
  {column label="Started" field="started" mode="raw"}
  {column sort="tracker_field_18" field="completed" label="Completed"}
{OUTPUT}
  {FORMAT(name="title_link")}{display name="title" format="objectlink"}{FORMAT}
  {FORMAT(name="started")}{display name="tracker_field_started" format="trackerrender" editable=inline}{FORMAT}
  {FORMAT(name="tracker_field_completed")}{display name="tracker_field_completed"}{FORMAT}
{LIST}
{CODE}

{LIST()}
{pagination max="12"}
{filter field="tracker_id" content="17"}
{filter type="trackeritem"}
{OUTPUT(template="table")}
  {column sort="title" label="Title" translatelabel="y" field="title_link" mode="raw"}
  {column label="Started" field="started" mode="raw"}
  {column sort="tracker_field_completed" field="completed" label="Completed"}
{OUTPUT}
  {FORMAT(name="title_link")}{display name="title" format="objectlink"}{FORMAT}
  {FORMAT(name="started")}{display name="tracker_field_started" format="trackerrender" editable=inline}{FORMAT}
  {FORMAT(name="completed")}{display name="tracker_field_completed"}{FORMAT}
{LIST}

Note that the -+column+- controls (within OUTPUT) are converted to a data array sent to the template. The table formatting uses ((Smarty)) formatting and provides the same capabilities.

(Tiki 18+) -+translatelabel="y"+- will translate the column label provided the translation is known to Tiki.

The use of the FORMAT control blocks allows individual objects to be 'formatted' and then referenced in the various OUTPUT methods - see ((PluginList format control block)) for more details.

!!! Download CSV of Table Results
Since ((Tiki18)) the -+downloadable=filename.csv+- parameter can be used to add a Download button which generates a CSV file with all data found in the table. Header row is based on the table headers formatted via -+column+- mode parameter. This option is ===available if you use the "table" output=== (see: [https://doc.tiki.org/PluginList-output-control-block#Download_CSV_of_Table_Results|Download CSV of Table Results] ~tc~or if you have developers skills, reusing the code from the table template (templates/search/list/table.tpl) into your own template~/tc~. What is interesting in this option is that ===it will export ALL the results=== found for the search query and not only the list displayed (pagination may limit the visible list of results).

This option is also available when using the ((PluginCustomSearch|CustomSearch plugin)) and the ((PluginListExecute|List Execute plugin)).

This option has been improved in Tiki25 offering an option to position the download button when using the table.tpl template.

{CODE(caption="Output formatting with download option" wrap="1" colors="tiki")}
{filter content="22" field="tracker_id"}
{OUTPUT(template="table" downloadable="Sample file.csv")}
  {column label="Firstname" field="firstname"}
  {column label="Lastname" field="lastname"}
{OUTPUT}
  {FORMAT(name="firstname")}{display name="tracker_field_contactsFirstName"}{FORMAT}
  {FORMAT(name="lastname")}{display name="tracker_field_contactsLastName" format="trackerrender"}{FORMAT}
{CUSTOMSEARCH}
{CODE}

Since ((Tiki25)) the -+ downloadable-position="top|bottom|both" +- parameter controls position of the Download button has been added. Values are -+top+-,-+bottom+- or -+both+-. Default is "bottom".
{CODE(caption="Output formatting with download option" colors="tiki")}
{OUTPUT(template="table" downloadable="Sample file.csv" downloadable-position="top")}
...column specification...
{OUTPUT}
{CODE}

!!! Table formatting with tablesorter
Starting with ((Tiki15)), PluginList can be used with ((Tablesorter|tablesorter)). Use a -+{tablesorter}+- tag to add the tablesorter parameters. See below, which uses the same syntax as above except for the addition of the tablesorter tag:

{CODE(caption="Sample with tracker list and calculation")}
{LIST()}{pagination max="12"}
{filter field="tracker_id" content="17"}
{OUTPUT(template="table")}
{column label="Month" field="month" mode="raw"}
{column label="Started" field="started"}
{column label="Completed" field="completed"}
{column label="Status" field="status"}
{tablesorter server="n" sortable="type:reset" tsortcolumns="type:text|type:none|type:none|type:text" tsfilters="type:nofilter|type:nofilter|type:nofilter|type:dropdown;empty:empty" tstotals="| |type:col;label:Total hours|" tstotaloptions="ignore|ignore| |ignore" tstotalformat="#,###."}
{OUTPUT}
{FORMAT(name="month")}{display name="tracker_field_month" format="objectlink"}{FORMAT}
{FORMAT(name="started")}{display name="tracker_field_started"}{FORMAT}
{FORMAT(name="completed")}{DIV(type="span" class="float-right")}{display name="tracker_field_completed"}{DIV}{FORMAT}
{FORMAT(name="status")}{display name="tracker_field_status" default=""}{FORMAT}
{LIST}
{CODE}

Will produce the following (note that a span and bootstrap class are added to align the numbers as by default tablesorter calculation are numbers aligned right)

{LIST()}{pagination max="12"}
{filter field="tracker_id" content="17"}
{OUTPUT(template="table")}
{column label="Month" field="month" mode="raw"}
{column label="Started" field="started"}
{column label="Completed" field="completed"}
{column label="Status" field="status"}
{tablesorter server="n" sortable="type:reset" tsortcolumns="type:text|type:none|type:none|type:text" tsfilters="type:nofilter|type:nofilter|type:nofilter|type:dropdown;empty:empty" tstotals="| |type:col;label:Total hours|" tstotaloptions="ignore|ignore| |ignore" tstotalformat="#,###."}
{OUTPUT}
{FORMAT(name="month")}{display name="tracker_field_month" format="objectlink"}{FORMAT}
{FORMAT(name="started")}{display name="tracker_field_started"}{FORMAT}
{FORMAT(name="completed")}{DIV(type="span" class="float-right")}{display name="tracker_field_completed"}{DIV}{FORMAT}
{FORMAT(name="status")}{display name="tracker_field_status" default=""}{FORMAT}
{LIST}



{CODE(caption="Sample adding tablesorter functionality" colors="tiki")}
{LIST()}
   {filter type="trackeritem"}
   {filter content="water"}
   {OUTPUT(template="table")}
       {column sort="title" label="Title" field="title_link" mode="raw"}
       {column label="Description" field="description"}
       {column sort="tracker_field_18" field="event_date" label="Event Date"}
       {tablesorter server="n" sortable="type:reset" tsortcolumns="type:text|type:text|type:digit" tsfilters="type:text|type:dropdown|type:digit" tspaginate="max:10" tscolselect="critical|5|6"}
   {OUTPUT}
   {FORMAT(name="title_link")}{display name="title" format="objectlink"}{FORMAT}
   {FORMAT(name="event_date")}{display name="tracker_field_18" format="date"}{FORMAT}
{LIST}
{CODE}

{LIST()}
   {filter type="trackeritem"}
   {filter content="water"}
   {OUTPUT(template="table")}
       {column sort="title" label="Title" field="title_link" mode="raw"}
       {column label="Description" field="description"}
       {column sort="tracker_field_18" field="event_date" label="Event Date"}
       {tablesorter server="n" sortable="type:reset" tsortcolumns="type:text|type:text|type:digit" tsfilters="type:text|type:dropdown|type:digit" tspaginate="max:10" tscolselect="critical|5|6"}
   {OUTPUT}
   {FORMAT(name="title_link")}{display name="title" format="objectlink"}{FORMAT}
   {FORMAT(name="event_date")}{display name="tracker_field_18" format="date"}{FORMAT}
{LIST}

Please note that in some cases, if you want to use the tsfilters, you will need to take into account an extra column at the beginning for the:
* status field
* checkbox to perform actions on the listed items through the ((PluginListExecute))  
+ you can safely pre-pend, for instance, a "type:nofilter|" at the begining of the parameters of the tsfilter in such cases.

!!! Table: expand table, number of items found, optional title
Starting with ((Tiki20)), PluginList has a few optional parameters that work in conjunction with the __table__ built-in template. Use a -+{tableparams}+- tag to add these parameters:
* __allowtableexpansion__: for allowing table expansion (a toggle button to allow wide tables to overflow to the right of the content area rather than be scrollable in a limited-width area) (backported to 19.1 and 18.4)
* __shownbitems__: to show the number of items found. (backported to 19.1 and 18.4)
* __title__: whatever string you use here will be shown above the results table, with tiki syntax. The main purpose of this parameter is to allow for the title ''not to show'' when there are no results found. (backported to 19.2 and 18.4)
See usage example below:

{CODE(caption="Table showing items count and with an expand button" colors="tiki")}
{LIST()}
  {filter content="1" field="tracker_id"}
{OUTPUT(template="table")}
    {tableparams allowtableexpansion="y" shownbitems="y" title="!This is the title
And this is the subtitle"}
    {column label="Book Title" field="book_title"}
    {column label="Author" field="author"}
    {column label="Pages" field="pages"}
    {column label="Year" field="year"}
{OUTPUT}
  {FORMAT(name="book_title")}{display name="tracker_field_bookTitle"}{FORMAT}
  {FORMAT(name="author")}{display name="tracker_field_bookAuthor"}{FORMAT}
  {FORMAT(name="pages")}{display name="tracker_field_bookPages"}{FORMAT}
  {FORMAT(name="year")}{display name="tracker_field_bookYear"}{FORMAT}
{LIST}
{CODE}

!!Media List Formatting
((Tiki13))+
This sample presents a list of ((Goals|badges)) obtained by the current user.
{CODE(caption="Sample using the default media list formatting" colors="tiki")}
{LIST()}
  {filter relation="{{user}}" objecttype="user" qualifier="tiki.badge.received.invert"}
  {OUTPUT(template="medialist")}
    {icon field="tracker_field_image"}
    {body field="tracker_field_description"}
  {OUTPUT}
{LIST}
{CODE}

{LIST()}
  {filter relation="{{user}}" objecttype="user" qualifier="tiki.badge.received.invert"}
  {OUTPUT(template="medialist")}
    {icon field="tracker_field_image"}
    {body field="tracker_field_description"}
  {OUTPUT}
{LIST}

!!Carousel Formatting
((Tiki14))+

Parameters
|| Parameter | Values | default (empty)
mode | carousel-slide, carousel-fade, ... | carousel-slide
indicators | y, n | y
controls | y, n | y ||

This sample presents agile gallery of images as a Bootstrap Carousel.
{CODE(caption="Sample using the default Bootstrap Carousel formatting" colors="tiki")}
{LIST()}
  {filter field="gallery_id" content="1"}
  {OUTPUT(template="carousel")}
    {carousel interval="2000" wrap="true" pause="hover" id="mycarousel"}
    {body field="pic" mode="raw"}
    {caption field="caption"}
  {OUTPUT}
  {FORMAT(name="pic")}{display format="wikiplugin" name="wikiplugin_img" fileId="object_id" styleimage="width:100%"}{FORMAT}
  {FORMAT(name="caption")}
!!! {display name="title" default="Untitled"}
{display name="description" default=""}{FORMAT}
{LIST}
{CODE}

!!! Carousel parameters
''New parameters are added regularly and you can check them by looking at "templates/search/list/carousel.tpl" ''
* interval
* pause
* wrap
* indicators (y/n; to hide or show the small indicators below the content)
* controls
* pagination

!!! Example
{DIV(style="min-height: 800px")}
{LIST()}
  {filter field="gallery_id" content="1"}
  {OUTPUT(template="carousel")}
    {carousel interval="2000" wrap="true" pause="hover" id="mycarousel"}
    {body field="pic" mode="raw"}
    {caption field="caption"}
  {OUTPUT}
  {FORMAT(name="pic")}{display format="wikiplugin" name="wikiplugin_img" fileId="object_id" styleimage="width:100%"}{FORMAT}
  {FORMAT(name="caption")}
!!! {display name="title" default="Untitled"}
{display name="description" default=""}{FORMAT}
{LIST}
{DIV}

!!! Fade Example
In Tiki 18 you can use a fade transition by adding -+mode="fade"+- to the carousel tag, and after Tiki 19+ you should use  -+mode="carousel-fade"+-
{DIV(style="min-height: 800px")}
{LIST()}
  {filter field="gallery_id" content="1"}
  {OUTPUT(template="carousel")}
    {carousel interval="2000" wrap="true" pause="hover" id="mycarousel" mode="carousel-fade"}
    {body field="pic" mode="raw"}
    {caption field="caption"}
  {OUTPUT}
  {FORMAT(name="pic")}{display format="wikiplugin" name="wikiplugin_img" fileId="object_id" styleimage="width:100%"}{FORMAT}
  {FORMAT(name="caption")}
!!! {display name="title" default="Untitled"}
{display name="description" default=""}{FORMAT}
{LIST}
{DIV}

!!Count Formatting
((Tiki15))+
This sample shows how to return a simple count of the number of tracker items in tracker 7. For best performance, it is advised to set the max returned results to 1 to prevent having the index to send all the info for all the results (which will slow the request down unnecessarily). 
{CODE(colors="tiki")}
{LIST()}
  {pagination max=1}
  {filter type="trackeritem"}
  {filter field="tracker_id" content="7"}
  {OUTPUT(template="count")}
  {OUTPUT}
{LIST}
{CODE}

{LIST()}
  {pagination max=1}
  {filter type="trackeritem"}
  {filter field="tracker_id" content="7"}
  {OUTPUT(template="count")}
  {OUTPUT}
{LIST}


!!Report Formatting
((Tiki20))+
This allows you to have specific output format in a wiki page using the CALC extension (extend the wiki plugin List) to execute a formula on the whole result set returned by the list plugin, thus - do aggregations on the data. Useful for reports on more than one tracker item or the whole search result set.

(also see ((Calculations|#Syntax|Calculations Syntax)))

Example:
{CODE(colors="tiki")}
{LIST()}
{filter field="tracker_id" content="45"}
{filter type="trackeritem"}
{OUTPUT(report="y")}
There are {CALC()}(count results){CALC} entries.
The total amounts are {CALC()}
(add (for-each (list results) (formula (if (equals tracker_field_trCurrency (str USD)) tracker_field_trAmount 0))))
{CALC} USD and {CALC()}
(add (for-each (list results) (formula (if (equals tracker_field_trCurrency (str MOP)) tracker_field_trAmount 0))))
{CALC} MOP.
{OUTPUT}
{LIST}
{CODE}

The new subtotal function aggregates data based on a single column (username in our case) and applies an aggregate function to the rest of the columns (you can choose which ones and what functions to apply). The example aggregates time sheet entries based on the username and applies the 'add' function to the time sheet minutes and 'count' function to the invoice number field. At the end, we have the data in this format: 
user1|1250|3 
user2|140|1 
which is suitable for ((PluginFancyTable)). As you can see in the example, we put the results in a fancytable, so a nice-looking report is done. You can add as many filters to the LIST plugin as you want, so time-constrained data is returned.
{CODE(colors="tiki")}
{LIST()}
{filter field="tracker_id" content="22"}
{filter type="trackeritem"}
{OUTPUT(report="y")}
{FANCYTABLE()}
Username|Duration|Invoice
{CALC()}
(subtotal (list results) (group tracker_field_TimeSheetWorkerUsername) (aggregate tracker_field_TimeSheetMinutesWorked tracker_field_TimeSheetInvoiceFromFreelancer) (formula add count) (separators (str |) (str ~nl~)))
{CALC}
{FANCYTABLE}
{OUTPUT}
{LIST}
{CODE}

!!Wiki Formatting (Within Plugin)
For each result, the plugin allows to apply a template. See ((PluginList advanced output control block)).

!!!!All the LIST Plugin control blocks
{toc pagename="PluginList"}
        

History

Advanced
Information Version
Jonny Bradley 114
Jonny Bradley 113
Jonny Bradley 112
Jonny Bradley 111
Victor Emanouilov 110
Jonny Bradley 109
Jonny Bradley 108
Bernard Sfez / Tiki Specialist Improved the consistency of the parameters order for the table output 107
Marc Laporte 106
Bernard Sfez / Tiki Specialist 105
Bernard Sfez / Tiki Specialist 104
Bernard Sfez / Tiki Specialist 103
Bernard Sfez / Tiki Specialist 102
Bernard Sfez / Tiki Specialist Adding sample to add a popover from tracker display properties 101
Bernard Sfez / Tiki Specialist 100
Bernard Sfez / Tiki Specialist Adding information about the plugin list column class parameter 99
Bernard Sfez / Tiki Specialist 98
Torsten Fabricius bg plus style parameter did not work together, thus now this solution: {DIV(style="clear: both; min-height: 800px; background-color: #dddddd;")} 97
Torsten Fabricius fixed typo: bg=dddddd ->bg="#dddddd" 96
Torsten Fabricius added a clear and a background colour to the gallery DIV, ti reduce confusion when image is missing 95
Torsten Fabricius 94
Bernard Sfez / Tiki Specialist WIP about reusing the code 93
Bernard Sfez / Tiki Specialist Improving documentation for the downloadable option using the table template 92
Jonny Bradley 91
Jean-Marc Libs 90
Jean-Marc Libs 89
Bernard Sfez / Tiki Specialist added carousel parameters list 88
Bernard Sfez / Tiki Specialist 87
Bernard Sfez / Tiki Specialist Adding carousel parameters information 86
Bernard Sfez / Tiki Specialist 85
Bernard Sfez / Tiki Specialist Fixe sample so it shows something - could be improved but no more free time 84
Bernard Sfez / Tiki Specialist editable inline for table template; Corrected required parameters, added sample 83
luciash d' being 🧙 82
Bernard Sfez / Tiki Specialist Correction on the Calc extension (not a wiki plugin) 81
luciash d' being 🧙 prevent jumps of the content 80
luciash d' being 🧙 79
luciash d' being 🧙 78
luciash d' being 🧙 77
Jean-Marc Libs 76
Jonny Bradley added note about fade mode (better late than never?) 75
Roberto Kirschbaum 74
Roberto Kirschbaum Updated section on table.tpl parameters 73
lindon 72
Bernard Sfez / Tiki Specialist Adding float-right span to align numbers for the tablesorter + calculation sample [Rollback by lindon to version 55] [Rollback by lindon to version 60] [Rollback by lindon to version 64] 71
lindon 70
lindon list Plugin modified by editor. 69
lindon list Plugin modified by editor. 68
lindon list Plugin modified by editor. 67
lindon list Plugin modified by editor. 66
lindon list Plugin modified by editor. 65