Structures

Page actions

Pretty Trackers

The concept of a pretty tracker is similar to the functionality of Drupal's CCK (Content Construction Kit) or Mediawiki infoboxes. It allows a site manager to design a form, use a tracker to manage that information, and have the results of each displayed in s customizable way.

e.g. Suppose you have a movie review site. You can create a tracker that asks for:

Title of Movie (text field)

Review (textarea field)

Rating (numeric field)

poster or picture (image field)

Trackers have the ability to change the order and size of these fields, and if you try you can get your tracker to display a reasonably clean arrangement. But (as always) you want more. You want to use all your html and css skills to arrange and style these reviews in your tracker exactly like so. Thats what pretty trackers are for.

Simple example of PluginTrackerlist without pretty tracker

A pretty tracker uses a template to display the item

Versions:They were introduced in Tiki2, while some extra features appeared later, (since Tiki3 ), etc. You can also use pretty trackers to do fancy stuff like multipage input forms.

Inside a Tracker or in a Wiki Page ?

There are are two ways in which pretty trackers are used.

A Pretty Tracker (in the tracker feature) is one that uses a template to customize the display of tracker items inside the tracker feature.

A Pretty Tracker (in the wiki) does the same thing within wiki pages, including via the PluginTrackerlist.

In Tiki6 functionality was added to have PluginTracker write directly to wiki pages using a template (discarding the tracker item after the page was created).

In all cases it is about displaying tracker items using a template.

Note

In tiki world a template can mean several similar things e.g. content templates all related to some kind of "coookie cutter functionality. TPL is short for Template and they can be used interchangably, here they both mean a page or a file having the instructions how to render some other page.

For wiki only - when using the pageselector you need to provide an example of a PluginTrackerlist to be copied to the output page

1 master copy per tracker)

Tracker Wiki Output TPL

R

N

A wiki page or tpl file used by the PluginTrackerList. Controls how the output for all items is displayed in various wiki pages.

1 per tracker, controls all items.

Tracker Item Output TPL

Y

Y

A wiki page or tpl file used by the tracker itself. Controls how the output for all items is displayed in the trackers item view.

1 per tracker, controls all items.

Tip

wiki pages used as a template needs to be assigned the perm tiki_p_use_as_template to the group of users that you plan that they will work with the pretty tracker, in order to work properly.

How it Fits Together

The following graphic depicts how a pretty tracker in a wiki page works, including how you can have a template for the input page as well as the output page.
Blue objects are seen by the end user. Green objects are behind the scenes, called by the plugins of the blue objects. Red arrows are representing the time sequence: input, processing, output.

The Pretty Tracker In Action

When executed the sequence in the code works like this.
1. The Input Page calls the PluginTracker, which calls the Tracker Input TPL
2. The Input Page is rendered in the browser as "pretty"
3. The End user supplies the input for the tracker's fields - in other words, fills out the form, which includes providing the name to the Page Selector that will become the title of a new wiki page.
4. The tracker item is created in the background.
5. If the tracker has an Item Display TPL, that is called to render the tracker item.
6. If a page selector exists a wiki page is created and filled with the content of the Tracker Display, which is normally just the pre-configured PluginTrackerList.
7. When the wiki page is visited, PluginTrackerlist calls up the fields from the tracker, and the Tracker Output TPL and combines them together to render the "pretty" page as seen by the end user.

Note

Pretty Tracker does not work when the option 'mirror tables' in Tracker Settings (Admin) is set

Tutorial - A Simple Pretty Tracker.

The step-by-step tutorial that follows will allow you to create a pretty tracker within the trackers function. This is a recommended first step to creating a more complicated pretty tracker. In this tutorial you will display a pretty tracker item using an Item Output TPL. If you get that far, you can use the template made here as the basis for a Pretty Tracker in a Wiki Output TPL.

Note: This tutorial assumes you know how to set up a tracker.

Create a normal tracker. You can "prettify" an existing tracker if you like. Please consult the docs on trackers to learn how if necessary. Here the Tracker name is Simple Tracker * Don't fill in the "Wiki page to display an item" yet (this is the last option in the edit tracker panel). We will fill that later.
* Note what tracker ID you have created. Here we will say it is trackerID=8

Create fields for your tracker. For now, don't spend time trying to change how they are displayed, or what order they are in or what size they are.

Create a few test items for your tracker if they don't already exist. The point here is to get to step 4 as quickly as possible. You can always add more fields later.

Go back and take a look at tiki-view_tracker.php?trackerId=8 (substitute your tracker ID in the url instead of 8) to see your tracker's items. All there? Good.

List your Tracker Field ID's Open a second browser and navigate back to tiki-admin_tracker_fields.php?trackerId=8 by clicking the Fields button. Keep this page open while you work on the next steps.

Creating the Output TPL Create a new wiki page called Simple Tracker Output TPL (replace 'Simple Tracker' with the name of your tracker. Don't be creative, use this naming convention to avoid confusion later.

In the new wiki page, key in a list of variables and field names using all the fieldID's you see in that other broswer window. Type in the fieldIDs as variables just like they are below.

So what we have here are placeholders that will be replaced by the information belonging to the individual tracker item field. The curly bracket things are the variables, that is what matters. You can delete the names after, but you need them for now to avoid confusion.

Now go nuts with your HTML, Smarty, and CSS skills. By editing Simple Tracker Output TPL you are creating a web page that presents all the fields in your tracker in a nice and pretty way. Copy and paste each variable from your list into the appropriate spot. Save.

Add special object permissions to this page. Assign the perm tiki_p_use_as_template to anonymous and registered, or whatever groups will be viewing the tracker. Save. You may have already set this using categories or global permissions, but now you are sure it will work.

Now (is your other window still open? Hope So). Go back to tiki-admin_trackers.php?trackerId=8 by clicking on the Trackers button, then click on the action wrench icon for tracker 8 and click on Properties in the popup. Within the modal popup click on Section Format to expand that section and perform the following:

Set the Section format field to Configured

Set "Template to display an item" to be wiki:Simple Tracker Output TPL. (you replaced 'Simple Tracker' with your trackers' name right?)

Save

Now go to tiki-view_tracker.php?trackerId=8, and select an item. How is this item displayed now? Kinda Pretty? you will probably have to edit your template page a couple more times to get the best result. You may also have to visit tiki-admin_tracker_fields.php?trackerId=8 to resize the fields you created (it doesn't make much sense to spend time on that till now.)

Tweak until satisfied.

Dynamic Pretty Trackers

So far the tracker inputs and outputs have been rather static. It is not possible to change a field according to the value of another field, for example.

But what if you want to have different questions or different answers displayed in your template based on the information in that item? Basic conditional display is covered by PluginTrackerToggle. Using pretty trackers and JavaScript, more advanced behavior is possible for those who know HTML, DOM and JavaScript. The following form uses the jQuery library and PluginJq:

The layout of this pretty tracker is defined in the template page Dynamic tracker example template, which also contains the code to make the form dynamic. The code below will use field numbers to control these field.

Field number

Name

121

Content type

122

File

123

URL

124

Did you ensure this does not breach policy?

Syntax changed since Tiki 7

Keep in mind that default syntax for tracker fields changed since Tiki7, so that when referring them from within plugin jquery, you have to update the syntax.

Tracker field IDs and names have changed to improve consistency: all tracker fields now use ins_XX, where XX is the fieldId.

Conditional fields

The form contains two alternative fields which are initially hidden. When a radio button is selected, the corresponding field appears. Since none of these fields is always required, the tracker fields are not defined as mandatory. But this is emulated using a JavaScript check when submitting the form.

The initial state is achieved with the following code:

$("#fileprompt").hide();
$("#urlprompt").hide();

fileprompt and urlprompt are the identifiers of DIV elements defined in the template to allow controlling the display of the 2 fields and their label:

The function is executed when field 121 is changed. When the function is executed, one of the 2 blocks is run depending on the value of the selected (or "checked") radio button.

Display a message when a certain value is selected

The user needs to fill a boolean field, but one value is not normal. A message is displayed if the user selects "No". The following code does this adding a handler to the change event on the select element:

Using a Pretty Tracker in a Wiki Page

Conditional display of input fields

Syntax tips

Pre-defined variables

{$f_created}: created date
{$f_status_input}: status input field (for plugin tracker with showstatus="y")
{$f_status}: status (output)
{$f_itemId}: the item id
{$f_lastmodif}: last modified date (this will display unix date, for human readable date look below)
(In Tiki 8 onwards) {$itemoff}: the iteration number of each item
{$tr_offset}: the offset of the item, i.e. this is the nth item of the total number of x items