History: PluginTracker
Preview of version: 173
Plugin Tracker
Use this wiki plugin to create a form for inputting an item into a tracker. You can specify what fields will be included in the form. In Tiki6, this plugin can also be used as a simple way to create custom forms which output the result as preformatted wiki pages instead of tracker items.
Table of contents
overwrite
parameter is only to overwrite tracker items (not wiki pages) - not useful when discarditem="y"
outputwiki
as template you cannot use Smarty syntax programmatically because the resulting output is static wiki page (not computed against an existing Tracker Item like with Pretty Trackers and TrackerLists) - you can use only {$f_XX}
to indicate the fields values or Argument variables. Administration
- You can limit the tracker fields that can be used in this plugin in the field admin panel of the tracker:
"Field is public? for use with trackerlist plugin option
For Tiki 9.x, the User Selector field (the "userId" field in your tracker, perhaps), edit the field, Permissions, Visibility, Visible by All (even though that's counter-intuitive (you want those items private to that use). - If you have a tracker that has only one item per user/IP or if you use the plugin with the param view=user, the plugin will automatically the item if already exists.
Examples
{TRACKER(trackerId="1" fields="1:3:4" action="Send")} Thank for your contribution! {TRACKER}
How to prefill some fields
In some situation you want to go in a TRACKER page (for our example named SubmitOrder ) where fields are automatically prefills. In this case you can use an URL like this:
tiki-index.php?page=SubmitOrder&autosavefields=1&autosavevalues=tikiwiki
When in the page SubmitOrder, you click on save the field 1 will be filled with the value tikiwiki. If the field 1 is multivaluated field(ex: category), the value will be added to the potentially additional value the user has selected whatever the user do.
Tip:
The construction of such url can use the feature 'Wiki argument variables'
(see Advanced Wiki Syntax usage examples)
tiki-index.php?page=SubmitOrder&autosavefields=2:3&autosavevalues={{itemId}}:{{page}}
You could also use the url parameter "prefills" with the corresponding "values". See more information here:
See also PluginTrackerList to see how to use the parameter url to transfer an itemId to an URL or PluginJQ if you want to use jQuery.
How to fill an item in more than one step
If you want to fill some fields of an item in a page and to fill some other ones in another page, you need to use the param url with the itemId option.
Example (uses SEFUrl enabled links):
Page1
{tracker trackerId="1" fields="1:2:3" url="Page2?itemId"}
Page2
{tracker trackerId="1" fields="4:5:6" url="Page3?itemId"}
Page3 - the final one that will display the currently submitted itemId:
{trackerlist trackerId="1" fields="1:2:3:4:5:6"}
It is also possible to use tabs and link to each tab using "cookietab".
Note that the tracker item will be saved by sequence so you better check that no mandatory fields rule are on the way.
{TABS(tabs="First Tab|Second Tab|Third Tab")} {tracker trackerId="1" fields="1:2:3" action="Next" url="pageName?cookietab=2&itemId"} ///// {tracker trackerId="1" fields="4:5:6" action="Next" url="pageName?cookietab=3&itemId"} ///// {TRACKER(trackerId="1" fields="7:8:9" action="Save")}Saved!{TRACKER} {TABS}
How to put multiple tracker plugins into a single transaction?
New in Tiki15
Plugin tracker's transaction feature enables a sequence of trackers to be chained into a single transaction, which is submitted only after the user submits the last tracker form. Otherwise the transaction is cancelled.
The easiest way to use the feature is to create a wiki page for each of the steps.
Here is an example.
- wiki page: Register+Step+1
Copy to clipboard{tracker trackerId="1" fields="2" action="Next" ignoreRequestItemId="y" registration="y" chosenGroup="Registered" transactionName="RegistrationTransaction" transactionStep="0" transactionFinalStep="n" url="Register+Step+2"} - wiki page: Register+Step+2
Copy to clipboard{tracker trackerId="2" fields="4" action="Finish" ignoreRequestItemId="y" transactionName="RegistrationTransaction" transactionStep="1" transactionFinalStep="y"}
The registration and the tracker records of trackerId 1 and 2 will only get saved after the user presses Finish on Register+Step+2.
How to write a template to display the form elements on the wiki page where is saved the plugin
As mentioned, in a template, use the {$f_id}
syntax to insert the value of fieldId=id.
It is also possible and nowadays recommended to use the {$f_permanentname}
syntax to insert the value of ''permanent name" of the tracker field instead of the id.
It is also recommended to use a specific custom prefix for all fields of a tracker (one prefix per tracker) to allow to reuse and to provide existing trackers easily with a profile. Syntax: {$f__prefix_permanentname}
. The prefix can be set in the tracker preference settings.
It is also possible to insert the ItemId itself, which is useful to create new wiki pages with tracker plugins inside. To do this you'll have to add an Auto-Increment Field to your tracker, with the appropriate options to auto-fill it with the itemId. This new field content (itemId value) can then be inserted in the template with the syntax seen above.
Since Tiki 15.1, wiki page templates can be (optionally) used for email notifications using the "wiki:page name tpl" format instead of template_name.tpl files in the templates/mail dir. Tiki will use a page "page name subject tpl" if found.
Please mind, that wiki pages are more for quick and easy use cases, for testing and for proof of concept, whilst .tpl files in the servers directory are more reliable and much better to handle in larger projects or for advanced use cases.
Mind: .tpl templates for emails are stored in the folder /templates/mail
How to go from TRACKERLIST to TRACKER on this item
{trackerlist trackerId="1" fields="1:2:3:4:5:6" url="Page1?itemId"}
How send email to a recipient when new tracker item is created
You can use the parameter email to send an email once the tracker item has been created.
- a template:
- placed in your tiki files in the templates/mail directory,
or - specified as a wiki page as "wiki:page name tpl",
- placed in your tiki files in the templates/mail directory,
- and you need to set an email address to monitor changes of the tracker, at the tracker properties level
("Trackers > edit tracker > Notifications > Copy activity to email").
The format for the parameters is : from|to|template.
- from is the sender email that will be used for the notification. Multiple address can be set (separate multiple addresses with a comma)
- to is the recipient(s) to who the email address will be sent.
Multiple address can be set (separate multiple addresses with a comma).
Since Tiki 11 (may be earlier) you can set a tracker field (same item) being used in the tracker plugin template (required). - template is the template(s) to be used for email subject and body. (separate template can be used)
Using several emails and several templates it is possible to send different email (different subject & body) to different people. (see exemple below) - The following values can be used for from and to:
email(s), username(s), fieldId(s) or createdBy
createdBy was added in ((Tiki 17|Tiki 17 (trunk) )) and might be backported to 16.
username sends to the email of the registered user account and createdBy sends to the email of the curently logged in creator of the item.
Since Tiki 15 .1, tracker plugin allow Items List fields to be used as the to or from fields in the email parameter. They wil be shown in the form as read only labels. This might be useful in cases such as:
- One tracker defines business shops, with its members to be notified of changes related to that shop. And...
- A second tracker handles data of products from shops, and they have:
- one field as Item link to relate the product with their corresponding shop where they sell it.
- another field from the second tracker is an items list, to indicate the person to be notified, as user defined in the first tracker for that shop.
- You use the email parameter in a plugin tracker call to tracker 2, using the field corresponding to the person (as field id in tracker 2) as the recipient or sender of the email.
Since Tiki 16.3, email recipients option allows to set fieldId of a UserSelector (including multiple users selected) and GroupSelector.
Basic plugin usage
single recipient, single template
{TRACKER(trackerId="1" fields="1:2:3" action="Send" email="sender@domain.com|recipient@domain.com|templatename.tpl")}{TRACKER}
single recipient (creator), default site sender, basic default template (for quick proof of concept)
{TRACKER(trackerId="15" action="Send" email="|createdBy|")} Thank you for submitting an issue. We will come back to you as soon as possible. What you want to do now: ((Issue Tracker|submit another issue)) or ((HomePage|browse the website)) ? {TRACKER}
single recipient (creator), custom sender, custom template for body, default basic subject
{TRACKER(trackerId="15" action="Send" email="info@example.com|createdBy|mytemplate.tpl")} Thank you for submitting an issue. We will come back to you as soon as possible. What you want to do now: ((Issue Tracker|submit another issue)) or ((HomePage|browse the website)) ? {TRACKER}
single recipient (creator), custom sender, custom template for body, custom subject template
{TRACKER(trackerId="15" action="Send" email="info@example.com|createdBy|mytemplate.tpl,mytemplate_subject.tpl")} Thank you for submitting an issue. We will come back to you as soon as possible. What you want to do now: ((Issue Tracker|submit another issue)) or ((HomePage|browse the website)) ? {TRACKER}
Advanced plugin usage
multiple recipients, single template
{TRACKER(trackerId="1" fields="1:2:3" action="Send" email="sender@domain.com|recipient_1@domain.com,recipient_2@domain.com,recipient_3@domain.com|templatename.tpl")}{TRACKER}
In this case it will be sent the same notification to recipient_1, recipient_2 and recipient_3.
multiple recipients, multiple templates
{TRACKER(trackerId="1" fields="1:2:3" action="Send" email="sender@domain.com|recipient_1@domain.com,recipient_2@domain.com,recipient_3@domain.com|templatename_a.tpl,templatename_b.tpl,templatename_c.tpl")}{TRACKER}
In this case each recipient will receive a different notification. recipient_1 will receive email using template_a, recipient_2 will receive email using template_b and recipient_3 will receive email using template_3.
creator plus second recipient, two different body templates and two different subjects
{TRACKER(trackerId="15" action="Send" email="info@example.com|admin@mysite.com,createdBy|admin-template.tpl,creator-template.tpl,admin-template_subject.tpl,creator-template_subject.tpl")} Thank you for submitting an issue. We well come back to you as soon as possible. What you want to do now: ((Issue Tracker|submit another issue)) or ((HomePage|browse the website)) ?) {redirect page="Test-Tracker-Creator-Email"} {TRACKER}
single recipient (field), custom sender, custom template to fill the tracker plugin, custom template for body, custom subject template
Wiki page
{TRACKER(trackerId="15" action="Send" email="info@exemple.com|12|mytemplate.tpl" wiki="Template page")}Thank you!{TRACKER}
Template page
{TR()}Name{TR}: {$f_11} {TR()}Email address{TR}: {$f_12}
When filling the form (using the template) the email address from the field 12 will be used as recipient.
Templates (to create the email subject and email body)
Each template needs two files, one for the subject one for the body. All the templates must be in the templates/mail directory or (since Tiki15.1) in wiki pages and specified as "wiki:page name tpl" (you have to include the "tpl" exact word in the name without a dot, and place it, for instance, at the end).
Email body and subject naming conventions
The naming of these files needs to be slightly different depending on whether you use template files on disk or wiki pages as templates.
Template files on disk
If you want to use smarty template files on disk:
- body: "mytemplate.tpl"
- subject: "mytemplate_subject.tpl"
Example:
{TRACKER(trackerId="1" fields="1:2:3" action="Send" email="sender@domain.com|recipient@domain.com|mytemplate.tpl")}{TRACKER}
Note that you don't specify the subject template in the tracker plugin call, but the subject needs to exist with the corresponding name ("mytemplate_subject.tpl" in this case) if you want to have the subject message customized.
Wiki pages as smarty templates
If you want to use wiki pages as smarty templates:
- body: "page name tpl"
- subject: and "page name subject tpl"
note that the tpl word (without a dot) needs to be prepended with the word "subject " (subject and a space)
Example:
{TRACKER(trackerId="1" fields="1:2:3" action="Send" email="sender@domain.com|recipient@domain.com|wiki:page name tpl")}{TRACKER}
Note that you don't specify the subject template in the tracker plugin call, but the subject needs to exist with the corresponding name ("page name subject tpl" in this case) if you want to have the subject message customized.
Subject template
Hello, the {tr}item{/tr} "{$f_name}" {tr}was modified at{/tr} {$server_name} in {$mail_trackerName}
Where {$f_name} will the content of the field name, {$server_name} is the domain name and {$mail_trackerName} is the tracker name.
Body template
{tr}Hello,{/tr} {tr}Title:{/tr} {$f_name} {tr}Description:{/tr} {$f_description} {tr}View the tracker item at:{/tr} {$mail_machine_raw}/tiki-view_tracker_item.php?itemId={$mail_itemId}
Template - variable list
Not all wiki variables works (pretty tracker syntax won’t work).
- $mail_date
- The current timestamp
- $mail_user
- User login
- $mail_itemId
- The tracker itemId
- $mail_item_desc
- The item "title"
- $mail_trackerId
- Tracker id
- $mail_trackerName
- Tracker name
- $mail_machine
- URL of the request (example:
https://doc.tiki.org/PluginTracker
)
- $mail_machine_raw
- URL of the site root (example:
https://doc.tiki.org
)
- $server_name
- Server name (example:
doc.tiki.org
)
- $status
- The item's new status (e.g. Open, Pending or Closed, translated)
- $f_123 or $f_permanentName
- Values of the fields
Related pages
See also:
- PluginTrackerlist - which displays a given tracker items.
- Plugin Tracker Advanced
- Pretty Tracker
- PluginList