Loading...
 

LIST - format command


The FORMAT command is used to create individually templated objects that can then be used in any of the individual OUTPUT methods.



Available filters

Name Description Boolean Sample Tiki Version
default Display a default value or a default file when no value is available no “empty”, “1140” (fileId) -
format format the displayed value to something different that the db value (human readable) no “trackerrender”, “date”, “objectlink” -


Note that in some cases the field that will be displayed has its own behavior and it can clash with the format you selected.
IE: A tracker field that is a “title” is pre-formated as a link. If you set the format as “objectlink” (or you set the display inside a link) the display will end broken as Tiki will try to display a link inside a link.

For the default parameter, it’s important to remember that the tracker field “Files” works a bit differently than the others with this parameter. The tracker field Files expect an Id from the File Gallery. When most of the other fields type will display the text of the default parameters the default for “Files” must be an existing file in a gallery. The file can be an “anonymous” portrait file or a plain white image or an image with only the text “Not Available”, etc. Whatever you feel right for your usage.

Basic example

In most of the examples shown in LIST - OUTPUT command and LIST - advanced output command you will see a FORMAT command will have been used. e.g. in the example shown for Table output as below, two FORMAT commands are used:

Sample using the default table formatting
{LIST()}
   {filter type="trackeritem"}
   {filter content="water"}
   {OUTPUT(template="table")}
       {column field="title_link" sort="title" label="Title"  mode="raw"}
       {column field="description" label="Description"}
       {column field="event_date" sort="tracker_field_18" label="Event Date"}
   {OUTPUT}

   {FORMAT(name="title_link")}{display name="title" format="objectlink"}{FORMAT}
   {FORMAT(name="event_date")}{display name="tracker_field_18" format="date"}{FORMAT}
{LIST}


The first FORMAT command defines an object with the name title-link that is displayed in a specific way - this object reference in then used in the column command in the body of the table OUTPUT. Similarly the second FORMAT command defines the event_date object which is also used in a column command.

A similar use of the FORMAT command allows the normal set of smarty variables, eg {user} etc, to be made available in smarty templates - for example:

Format example to reference a normal smarty variable
{FORMAT(name="theuser")} { {user} } {FORMAT}

 Note

The double brackets ( {{}} ) around user should have no spaces between them. Spaces are used here only to keep the user variable from being interpreted.

This creates a reference object theuser with the userId of the current user which can then be invoked in a server stored smarty template using the variable {$row.theuser}

Examples of the use of the FORMAT command (format and default value)


{LIST()}
  {filter field="tracker_id" content="1"}
  {filter field="tracker_status" content="o"}
  {OUTPUT()}
        {DIV(class="h3")}{display name="name"}{DIV}
          {display name="photo"}%%%
          {display name="email"}
  {OUTPUT}
  {FORMAT(name="name")}{display name="tracker_field_userName"}{FORMAT}
  {FORMAT(name="photo")}{display name="tracker_field_userPhoto" format="trackerrender" default="1140"}{FORMAT}
  {FORMAT(name="location")}{display name="tracker_field_userLocation" format="trackerrender" default="Unknown"}{FORMAT}
{LIST}


Default parameter applied on the “photo” field will display a default generic image if not file found.
Default parameter applied on the “location” field will display the text “Unknown” if the field is empty.

Table with check marks instead of content when values found

In case you wanted a table with check marks (ticks) for if certain fields were filled in, rather than showing the actual data showing, you can use this code:
{LIST()}
  {filter field="tracker_id" content="42"}
  {OUTPUT(template="table")}
    {column label="Title" field="title" sort="title"}
    {column label="Has Data" field="hasData"}
  {OUTPUT}
  {FORMAT(name="hasData")}{DIV(class={display name="tracker_field_data" default="hidden"} title="Has some data")}{icon name="check-circle"}{DIV}{FORMAT}
{LIST}

So the 2nd column uses a FORMAT plugin where the contents of the field in question, tracker_field_data, is used as the class for a div but the default (used if the data field is empty) is set to be the bootstrap class “hidden” so the contents, the check mark, only appears if there is some data.

Obviously if the data is the name of some other class weird stuff might happen, but for most usual cases, it works as expected and saves having to make a new smarty template just for this simple list.

(Tip and example taken from a message from Jonnyb in the developers list - thanks!)

Using font awesome icons instead of content depending of the value of the field content


Tweaking the sample above and using font awesome (integrated in Tiki) you can display corresponding icons for a content.
In this demo case we have a tracker with a “gender” field that hold 2 values, “male” or “female”. There is a “male” and a “female” icons in font awesome as both use the ame term we can assign it to a div type icon and class.

{LIST()}
  {filter field="tracker_id" content="42"}
  {OUTPUT(template="table")}
    {column label="Title" field="title" sort="title"}
    {column label="Gender" field="gender"}
  {OUTPUT}
  {FORMAT(name="gender")}{DIV(type=i class=fa fa-{display name="tracker_field_gender"})}{DIV}{FORMAT}
{LIST}


It will display a if the content of the field = male and a if the content of the field = female.


When you use a template to display your plugin list you want other item related or linked to the item to open using the same template (or another it doesn’t matter) but not to open the trackers buildin system. For this you need to enable the Alias feature and set it to use the template to display the tracker item, “record-” for this sample.

When you use an item link to link an item to other item (related, friend of, etc.) this is a kind of a problem.
Item link has 2 option to display and item link. Value and Link.
Value display the id of the content (ie: 6)
Link display the value of the content linked to the tracker item (ie: Bernard)

Your link should be like:
[record-6|Bernard]

So it open the item “Id6” in the “record-” template showing the value “Bernard” for the link.
To achieve this you need to create and use 2 row.

{FORMAT(name="name")}{display name="tracker_field_contact" format=trackerrender}{FORMAT}
{FORMAT(name="id")}{display name="tracker_field_contact"}{FORMAT}


The first one with format=trackerrender will display the content of the tracker Item Link field as it is shown in the tracker (Bernard)
The second one without the format=trackerrender will show the real value for this field (6)

The assemble your link as follow:
[record-{display name="id"}|{display name="name"}]

It will complete the trick and open the item 6 using the record- template while the link displayed will show the right value, Bernard.

All the LIST Plugin commands



doc.tiki.org


Bootstrap

AdminGuide

UserGuide

Keywords

Keywords serve as “hubs” for navigation within the Tiki documentation. They correspond to development keywords (bug reports and feature requests):

Accessibility (WAI and 508)
Accounting (7.x)
Articles and Submissions
Backlinks
Banners
Batch (6.x)
BigBlueButton audio/video/chat/screensharing (5.x)
Blog
Bookmark
Browser Compatibility
Link Cache
Calendar
Category
Chat
Clean URLs
Comments
Communication Center
Compression (gzip)
Contacts (Address Book)
Contact us
Content Templates
Contribution (2.x)
Cookie
Copyright
Credit (6.x)
Custom Home and Group Home Page
Date and Time
Debugger Console
Directory of hyperlinks
Documentation link from Tiki to doc.tiki.org (Help System)
Docs 8.x
Draw 7.x
Dynamic Content
Dynamic Variable
External Authentication
FAQ
Featured links
File Gallery
Forum
Friendship Network (Community)
Gmap Google maps
Groups
Hotword
HTML Page
i18n (Multilingual, l10n, Babelfish)
Image Gallery
Import-Export
Install
Integrator
Interoperability
Inter-User Messages
InterTiki
Kaltura video management (4.x)
Karma
Live Support
Login
Logs (system & action)
Look and Feel
Lost edit protection
Mail-in
Map with Mapserver
Menu
Meta Tags
Mobile Tiki and Voice Tiki
Mods
Module
MultiTiki
MyTiki
Newsletter
Notepad
Payment
Performance Speed / Load
Permissions
Platform independence (Linux-Apache, Windows/IIS, Mac, BSD)
Polls
Profiles
Profile Manager
Report
Toolbar
Quiz
Rating
Feeds
Score
Search engine optimization
Search
Search and Replace
Security
Semantic links (3.x)
Shadowbox
Shadow Layers
Share
Shopping cart
Shoutbox
Slideshow
Smiley
Social Networks
Spam protection (Anti-bot CATPCHA)
Spellcheck
Spreadsheet
Stats
Surveys
Tags (2.x)
Task
Tell a Friend, alert + Social Bookmarking
TikiTests (2.x)
Theme CSS & Smarty
Trackers
Transitions (5.x)
TRIM
User Administration including registration and banning
User Files
User Menu
Watch
WebHelp
WebDAV (5.x)
Webmail
Web Services
Wiki 3D
Wiki History, page rename, etc
Wiki Page Staging and Approval (2.x)
Wiki Plugin extends basic syntax
Wiki Syntax
Wiki structure (book and table of content)
Workspace
WSOD
WYSIWYCA
WYSIWYG (2.x)
XMLRPC


Tiki Newsletter

Delivered fresh to your email inbox!
Newsletter subscribe icon
Don't miss major announcements and other news!
Contribute to Tiki
Show php error messages