LIST - display
The DISPLAY control block (or block) is used when you want to display something in-place where you put it - either in the body of a FORMAT block or directly in the body of the 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:
{DISPLAY(param="foo")}{DISPLAY}
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:
{display param="foo"}
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 Indexed Field you want to display or an alias which refers to name of the FORMAT block. - default
The DISPLAY 'plugin' can have an additionaldefaultparameter to specify the value to use if the object type does not contain the named value- use
default=" "to show a blank value instead ofNo value for ...when there is no value
- use
- 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 theseparator=""param below on them)- Optional
separatorattribute
- Optional
-
date: using the short date format- Optional
dateFormatto specify the date format using strftime (since 15.4 approx)
- Optional
-
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
nameattribute is the content for which you're searching - Optional
content_typeattribute is eitherhtmlwhen searching through html source, orforumpost(default for backwards compatibility) to search for images in a forum. - ''Example use:
{FORMAT(name="images")}{display name=article_content format="imagegrabber" content_type="html" width="150" max="3" default="img/icons/synergiq-folder.png"}{FORMAT} - Return value for
htmlis in the following format, assuming a return of 3 images:
<img src='http://abc/imagea.jpg'> <img src='http://abc/imageb.jpg'> <img src='http://abc/imagec.jpg'>
- Mandatory
-
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+) -
snippet: to display the initial portion of the a large text- Optional
lengthattribute - Optional
suffixattribute
- Optional
-
reference: to display a link based on the value- Mandatory
typeattribute - Optional
separatorattribute - Use
format=referencefor tracker fields which arepage selectorfields, to assure that you link to the page whose name is contained in the tracker, rather than to the tracker record.
- Mandatory
-
trackerrender: to render a tracker field (when usingtrackerrenderthe Smarty variable$context.search_renderwill beyand 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&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: decimal=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"} - 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 withpagedescriptionset if themetatag_pagedescpreference is enabled.- Note: For both
pagedescriptionandpagetitleno filtering is performed on the content, so use plain text only and avoid non-alphanumeric characters.
- Note: For both
- editable
(Tiki 11+)editable="inline"will set the field to be editable for tracker fields when using formattrackerrender. Required: "Inline editing (found in trackers)" and column should be set to mode=raw. e.g:{column label="First Name" field="firstName" mode=raw} {FORMAT(name="firstName")}{display name="tracker_field_firstName" format="trackerrender" editable="inline"}{FORMAT} - 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.
Examples
General
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 a tracker item's status only
{display name="tracker_status" format="trackerrender"}
Wiki Plugin Formatting
(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}"}