Loading...
 
Skip to main content

History: PluginList display control block

Source of version: 56 (current)

Copy to clipboard
            {syntax type="markdown"  editor="wysiwyg"} # LIST - display

The DISPLAY control block is used when you want to display something in-place where you put it - either in the body of a ((PluginList FORMAT control block|FORMAT)) block or directly in the body of the ((PluginList OUTPUT control block|OUTPUT)) block or in a referenced custom template (Smarty tpl file or a wiki page).

## Syntax

DISPLAY block has two possible syntax options similar to ((Wiki-Plugin)) syntax. 
For example you could use: 
{CODE(colors="tiki")}{DISPLAY(param="foo")}{DISPLAY}{CODE}

But it seems the body of the DISPLAY block is never rendered anyway so it is obviously better to use the *lowercase* shortened version without the content part: 
{CODE(colors="tiki")}{display param="foo"}{CODE}

The `param="foo"` can be e.g. `format="plain"`. 
It is possible to omit the double quotes but it is recommended to use them for consistency just in case a value contains spaces.

### Parameters

- *name*
     mandatory parameter where you put the name of the ((Search and List from Unified Index|Indexed Field)) you want to display or an alias which refers to name of the ((PluginList format control block|FORMAT)) block.
- *default*
     The DISPLAY 'plugin' can have an additional `default` parameter to specify the value to use if the object type does not contain the named value 
    - use `default=" "` to show a blank value instead of `No value for ...` when there is no value
- *format*
     The DISPLAY 'plugin' can have an additional *format* parameter to specify custom display methods 
    - `plain` : as-is, default format (does not work with Arrays as is, you need to add the `separator=""` param below on them) 
        - Optional `separator` attribute
    - `count` : number of elements in a multivalue element 
        - Useful to count the number of results in sublists https://gitlab.com/tikiwiki/tiki/-/commit/1b8c4ac461d38d7d3593439f69cdb3f1925170d1 (Tiki 27+)
        - ''Example use: 
             {CODE(colors="tiki")}{SUBLIST(name="active_ptms" multiple="1")}
...
{SUBLIST}
{FORMAT(name="active_ptms_count")}{display name="active_ptms" format="count"}{FORMAT}{CODE}
    - `date` : using the short date format 
        - Optional `dateFormat` to specify the date format using [https://secure.php.net/manual/en/function.strftime.php|strftime] (since 15.4 approx)
    - `datetime` : using the short datetime format (Tiki8)
    - `timeago` : using the timeago.js formatting for more readable dates and times (Tiki16/15.3)
    - `imagegrabber` : automatically grabs images from a source that is provided. set format="imagegrabber" to use. 
        - Mandatory `name` attribute is the content for which you're searching
        - Optional `content_type` attribute is either `html` when searching through html source, or `forumpost` (default for backwards compatibility) to search for images in a forum.
        - ''Example use: 
             {CODE(colors="tiki")}{FORMAT(name="images")}{display name=article_content format="imagegrabber" content_type="html" width="150" max="3" default="img/icons/synergiq-folder.png"}{FORMAT}{CODE}
        - Return value for `html` is in the following format, assuming a return of 3 images: 
             {CODE(colors="htmlmixed")}<img src='http://abc/imagea.jpg'>
<img src='http://abc/imageb.jpg'>
<img src='http://abc/imagec.jpg'>{CODE}
    - `objectlink` : uses the value as the label to a link to the object
    - `slug` : render values out using the current wiki url scheme *(Tiki 18.2+)*
    - ` url` : render urlencoded values. Useful for building URLs *(Tiki 21.3+)*
    - `snippet` : to display the initial portion of the a large text 
        - Optional `length` attribute
        - Optional `suffix` attribute
    - `reference` : to display a link based on the value 
        - Mandatory `type` attribute 
            - Type can be: 
                - `comment`
                - `external` (or `external_extended`)
                - `forumpost` (or `forum post`)
                - `freetag`
                - `group` (n.b. Nowhere to link, at least, yet.)
                - `relation_source`
                - `relation_target`
                - `trackeritem`
                - `trackeritemfield`
                - `user`
                - `wiki` `wikipage` or `wiki page`
        - Optional `separator` attribute
        - Use `format=reference` for tracker fields which are `page selector` fields, to assure that you link to the page whose name is contained in the tracker, rather than to the tracker record.
    - `trackerrender` : to render a tracker field (when using `trackerrender` the Smarty variable `$context.search_render` will be `y` and can be used to have different formatting in the trackeroutput Smarty tpl)
    - `templaterender` : to use a field as a template *(Tiki 19)* - experimental, more info to come...
    - `wikiplugin` : Renders a wiki plugin in the list output 
        - `name` : plugin name, e.g. wikiplugin_img
        - `default` : fallback values for any parameters in url query format (e.g. `fileId=42&amp;caption=Not+Found`) *(Tiki 11)*
        - `content` : plugin content body
        - other plugin params *(Tiki 11)*
    - `categorylist`, to display category names instead of category id's. By default, it will display categories in html unordered lists; but you can produce a plain text list of category names when you add the parameter: separator=",". (Tiki =>16.2)+-
    - `number`, to display formatted number using php number_format function. Accepts parameters: decimals=0 (number of decimal digits), dec_point=. (decimal point character), thousands_sep=, (thousands separator character). (Tiki =>17.0)+-
    - `currency`, to display currency field in different currency using exchange rates for a given date. Accepts parameters: target_currency=USD (the currency to display data in), date=tracker_field_transactionsDate (permanent name of a tracker field holding date of exchange rate or a formatted date here), symbol=y|n (default y meaning to use currency symbol, n meaning to use currency code). (Tiki =>19.0)+-
- *list_mode*
     (Tiki 9+) `list_mode="y"` can be added to use the list display settings for that field. e.g. `{display name="tracker_field_42" format="trackerrender" list_mode="y"}`; other option is `list_mode="csv"` to display as plain text value
- *pagetitle*
     (Tiki 9+) `pagetitle="y"` will set the browser title to the contents of the field for the first item found in the results with page title set (useful for single item result pages)
- *pagedescription*
     (Tiki 11+) `pagedescription="y"` will set the page's meta description tag to the contents of the field for the first item found in the results with `pagedescription` set if the `metatag_pagedesc` preference is enabled. 
    - **Note:** For both `pagedescription` and `pagetitle` no filtering is performed on the content, so use plain text only and avoid non-alphanumeric characters.
- *editable*
     (Tiki 11+) `editable="inline"` will set the field to be editable for tracker fields when using format `trackerrender`. Required: "Inline editing (found in trackers)" and column should be set to mode=raw. e.g: 
    {CODE(colors="tiki")}
{column label="First Name" field="firstName" mode=raw}
{FORMAT(name="firstName")}{display name="tracker_field_firstName" format="trackerrender" editable="inline"}{FORMAT}
{CODE}
- The **FORMAT** 'plugin' allows to apply a wiki template and store it inside a named value. The value can then be used inside an other wiki template, or more usefully inside a smarty template.
- *Action*
    - There is no built in "actions" field (edit, delete, etc.) for PluginList yet (March 2021) so you have to use a custom configuration. An example in wiki syntax is listed below.

### Examples

#### General

{CODE(colors="tiki" theme="default")}Display blog post with title (yes, you can use vanilla HTML code in the OUTPUT)
<h2>{display name="title" format="objectlink"}</h2>
{display name="blog_content"}

Display shortened blog post snippet
{display name="blog_content" format="snippet" length="96" suffix="…"}

Display category links
{display name="categories" format="reference" type="category"}

Display freetag links
{display name=freetags" format="reference" type="freetag"}

Display item link
{display name="tracker_field_42" format="trackerrender"}
{display name="tracker_field_42" format="reference" type="trackeritem"}

Display start of a wiki page
{display name="wiki_content" format="snippet" length="500 " suffix="..."}

Display a username and real name (e.g. for blog posts) with link to user info:
{display name="contributors" format="reference"}
{display name="contributors" format="reference" type="user"}

Display field in FORMAT block referenced via alias "foo"
{display name="foo"}

(Please note FORMAT must be always outside of the OUTPUT)
{OUTPUT()}Preview of the Foo: {display name="foo"}{OUTPUT}
{FORMAT(name="foo")}{display name="wiki_content" format="snippet" length="500 " suffix="..."}{FORMAT}

(Tiki 8) Categories
(n.b. does not seem to work on the mysql engine, checked in Tiki 12 and 14 - not tried Lucene)
{display name="categories" format="categorylist" singleList="y"}
{display name="categories" format="categorylist" requiredParents="15,20" excludeParents="5,6"}
{display name="categories" format="categorylist" singleList="y" separator=", "}

Display a time only
{display name="modification_date" dateFormat="%k:%M"}

Display only the year
{display name="tracker_field_dateOpening" format="date" dateFormat="%Y"}

Display a tracker item's status only
{display name="tracker_status" format="trackerrender"}


Display an 'action'
''Note: this is an example of only displaying 'Delete' Tracker item functionality, other functionality, for example 'edit' will be different''
{DIV(class="btn btn-danger text-white click-modal")}[tiki-tracker-remove_item?trackerId=11&modal=1&itemId={display name="object_id"}|{icon name="delete"}]{DIV}
{CODE}

#### Wiki Plugin Formatting

{CODE(colors="tiki" theme="default")}

(Tiki 9) Wiki Plugins
{display name="wikiplugin_addtocart" format="wikiplugin" code="tracker_field_42" description="tracker_field_43" price="tracker_field_44"}

(Tiki 11)
{display name="wikiplugin_img" format="wikiplugin" fileId="tracker_field_pic" thumb="box" default="fileId=42"}

If the wiki plugin needs a body, this goes into the content
{display name="wikiplugin_list" format="wikiplugin" content="{filter type=trackeritem} {filter field=tracker_id exact=4}" }
Note: this makes use of the fact that single-word parameters don't really need to be surrounded by double quotes. The same result is obtained with the more ugly:
{display name="wikiplugin_list" format="wikiplugin" content="{filter type=\"trackeritem\"} {filter field=\"tracker_id\" exact=\"4\"}" }

(Tiki 19 - backported to 18.4)
To replace parts of the content parameter with data from the results surround the field name with %percentages%
This example shows the number of comments on each tracker item
{display name="wikiplugin_list" format="wikiplugin" content="{filter type=comment} {filter field=parent_object_type content=trackeritem}{filter field=parent_object_id content=%object_id%}{output template=count}{ALTERNATE()} 0 {ALTERNATE}"}

(Tiki 27.2)
The same %percentages% delimited replacements now work in all plugin arguments - e.g.
{display name="wikiplugin_button" format="wikiplugin" content="{icon name=user} {TR()}Edit{TR}" href="tiki-tracker-update_item?trackerId=42&itemId=%object_id%&skip_preview=y" _class="click-modal"}

{CODE}

## Related

### All the LIST Plugin control blocks

{toc pagename="PluginList"}