Loading...
 
Skip to main content

History: PluginTrackerItemField

Source of version: 43 (current)

Copy to clipboard
            {syntax type="markdown"  editor="wysiwyg"} # Plugin Tracker Item Field

*Introduced in ((Tiki2))*

Use this ((wiki plugin)) to display or test the value of a field of a tracker item.

## Requirements

- The field must not be hidden
- To test or display a field, you must have the `tiki_p_view_trackers` (or `tiki_p_view_trackers_pending` or `tiki_p_view_trackers_closed` permission depending on the status of the item
- The status can be tested without permission

## Parameters

{pluginmanager plugin="trackeritemfield"}

### Limitation

The field must be a simple value (not computed, not item list). The tracker item can be specified by its ID with the `itemId` plugin param. If it is not specified and the url used to access the page has a `itemId` parameter, the value of `itemId` parameter will be used. If after this test is not set and if the ((User Tracker)) feature is set on, the user item of the user will be selected.

## Examples

For example, you have a user tracker with a field containing the phone number of the user, you can use this plugin with the `fieldId=phone_field_id` to display in the page the phone number of the user looking at the page: 
{CODE(colors="tiki")}
{trackeritemfield fieldId="1"}
{CODE}

Another example, you want to add a link in a page to a page where a user can fill his user tracker only if the user has no user tracker. You can use this plugin with the fieldId that is the user selector field. 
{CODE(colors="tiki")}
{TRACKERITEMFIELD(fieldId="1" test="1")}Welcome new member, please visit ((this_page)) to fill up your information{TRACKERITEMFIELD}
{CODE} 
A field can be tested against a value 
{CODE(colors="tiki")}
{TRACKERITEMFIELD(fieldId="1" test="1" value="toto")}Yes your name is toto{TRACKERITEMFIELD}
{CODE} 
See ((Tracker Field Types)) for values to match for special fields such as checkboxes.

If you want to do the same thing with a tracker that is not the user tracker but has only one item per user and has a field user selector/1, you can specify the tracker ID like this 
{CODE(colors="tiki")}
{trackeritemfield trackerId="1" fieldId="1"}
{TRACKERITEMFIELD(trackerId="1" fieldId="1" test="1")}Please fill out your review{TRACKERITEMFIELD}
{CODE}

It is also possible to test the status of the user item. For instance if you want to display something only if the item is pending or closed: 
{CODE(colors="tiki")}
{TRACKERITEMFIELD(status="pc")}Sorry, your survey is being processed{TRACKERITEMFIELD}
{CODE}

It is also possible to test if all the fields of as item are not empty: 
{CODE(colors="tiki")}
{TRACKERITEMFIELD(trackerId="1" fields="")}Thank you your form is complete{TRACKERITEMFIELD}
{CODE}

It is also possible to test an alternative: 
{CODE(colors="tiki")}
{TRACKERITEMFIELD(fieldId="1" test="1")}OK{ELSE}NOT OK{TRACKERITEMFIELD}
{CODE}

It is possible to have multiple levels of ELSE: 
{CODE(colors="tiki")}
{TRACKERITEMFIELD(fieldId="1" test="1")}OK{ELSE}{TRACKERITEMFIELD(fieldId="2" test="2")}super ok{ELSE}NOT OK{TRACKERITEMFIELD}{TRACKERITEMFIELD}
{CODE} 
Note the order the other test with always be in the ELSE part.

This plugin is also very useful when you want to show only some filtered values from a tracker field and for empty ones - to hide the messy warnings like "No value for 'tracker_field_xxx".

{CODE(colors="tiki")}
{LIST()}
{pagination max=10}
{filter field="tracker_id" content="2"}
{OUTPUT(template="table")}
  {column label="Id" field="itemid" class="text-left" mode="raw"}
  {column label="object_id" field="object_id"}
  {column label="Name" field="name" sort="name" class="text-nowrap"}
  {column label="Discount" field="discount"}
{OUTPUT}
  {FORMAT(name="itemid")}{display name="tracker_field_shopProductId" format="trackerrender"}{FORMAT}
  {FORMAT(name="object_id")}{display name="object_id"}{FORMAT}
  {FORMAT(name="name")}{display name="tracker_field_shopProductName"}{FORMAT}
  {FORMAT(name="discount")}
    {TRACKERITEMFIELD(trackerId="2" fieldId="143" itemId={display name="object_id"} test="0" value="")}
       {display name="tracker_field_shopProductDiscount" format="trackerrender"}
    {TRACKERITEMFIELD}
  {FORMAT}
{LIST} 
{CODE}

The trick here is to assign itemId value like this: 
{CODE(colors="tiki")}
itemId={display name="object_id"}
{CODE}

## Related

- ((PluginTrackerIf))
- ((PluginTrackerToggle))

## Aliases

- (alias(Mod trackeritemfield))