Fullscreen
[Show/Hide Right Column]

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
Image
A pretty tracker uses a template to display the item
Image


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 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).

Either way it is about displaying tracker items using a template.

noteNote
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.


Quick Step by Step Guide to a Pretty Tracker

Please read this Pretty Tracker HowTo first.


Parts of a Pretty tracker

A pretty tracker has several moving parts that are chained together. Not all will require all the parts below but this is the whole list. In the table below R=Required, Y=Can be used, N=Not used.

PartUsed in WikiUsed in TrackerDescriptionHow many?
TrackerRRThe tracker is the table that holds the dataOnly one.
Tracker Fields infoRRthe columns of the table / fields of the formMore than one
PluginTracker YYIf used replaces the "create a new item" in the tracker function.1 for each input location (can be more than one)
Tracker Input TPLYNIf PluginTracker is used this can controls how the input form should look1 for each PluginTracker
Output PageYN A wiki page where the single item results will show in a wiki. Usually pagename = item name (the "links to item" field of the tracker)1 per item
Tracker ItemYY All trackers will have items visible in the tracker feature. For the PTW this is redundant, or only used by admins. 1 per Item
Page Selector FieldYNMust be used to make a PTW where each item is associated with a page.1 per tracker
Display templateRNFor wiki only - when using the pageselector you need to provide an example of a PluginTrackerlist to be copied to the the output page1 master copy per tracker)
Tracker Wiki Output TPLRNA 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 TPLYYA wiki page or tpl file used by the by the tracker itself. Controls how the output for all items is displayed in the trackers item view.1 per tracker, controls all items.


noteTip
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.
Image

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.

noteNote
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.

Image

Note: This tutorial assumes you know how to set up a tracker.
1. 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
2. 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.
3. 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.
4. Go back and take a look at yourdomain.org/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.
5. List your Tracker Field ID's Open a second browser and navigate back to tiki-admin_tracker_fields.php?trackerId=8. Keep this page open while you work on the next steps.
6. 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.
7.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.
{$f_12} Username
{$f_13} City
{$f_14} Photo
{$f_15} Join Date
{$f_16} Wants to Buy
{$f_17} Wants to Sell
{$f_18} GroupName

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.
8. 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.
9. 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.
10. Now (is your other window still open? Hope So) Go back to go back to tiki-admin_trackers.php?trackerId=8&show=mod and Set "Wiki page to display an item" to be wiki:Simple Tracker Output TPL. (you replaced 'Simple Tracker' with your trackers' name right?) Save.
11. Now goto tiki-view_tracker.php?trackerId=8 How does it look. 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.)
12. 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? Using pretty trackers and JavaScript, this is possible for those who know HTML, DOM and JavaScript. The following form uses the jQuery library and PluginJq:


Select whether you want to upload a file or link to a URL
Content type:

File:


URL:

Did you ensure this does not breach policy?

Anti-Bot verification code image



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 numberName
121Content type
122File
123URL
124Did you ensure this does not breach policy?


warningSyntax 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.

For more information, read: http://doc.tiki.org/Tiki7#Upgrade_notes


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:

{DIV(type="div",id="fileprompt")}
File: {$f_122}
{DIV}
{DIV(type="div",id="urlprompt")}
URL: {$f_123}
{DIV}


The following code handles selection of a radio button, showing a field and making sure the other one is hidden:
$("input[name='track_121']").change(function(){
   if ($(this).filter(":checked").val() === 'File') {
      $("#urlprompt").hide();
      $("#fileprompt").fadeIn();
   } else {
      $("#fileprompt").hide();
      $("#urlprompt").fadeIn();
   } 
});

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:

$("select[name='track_124']").change(function(){
   if ($(this).find("option:checked").attr("value") === 'No') {
     alert("Then go do your homework.");
   } 
});

Using a Pretty Tracker in a Wiki Page

see Pretty Tracker in a Wiki Page

Conditional display of input fields


Attached to this wiki page as a downloadable PDF and MS Word files.

Syntax tips

{$f_created}: created date
{$f_status_input}: status input field
{$f_status}: status (output)
{$f_itemId}: the item id
{$f_lastmodif}: last modified date
(In Tiki 8 onwards) {$itemoff}: the iteration number of each item

Related
See:

Aliases: PrettyTracker | PrettyTrackers | Pretty Trackers


Contributors to this page: Marc Laporte9140 points  , xavi67871 points  , carsten.aevermann1138 points  , luciash d' being2160 points  , Nelson810 points  , Gregor (gta74)878 points  , mlpvolt4388 points  , Philippe Cloutier1008 points  , mlaporte164 points  , sylvie7387 points  , hastic484 points  , hans33241 points  , Ed20929 points  , lindon132 points  and shawnadler46 points  .
Page last modified on Sunday 15 April, 2012 03:12:43 UTC by Marc Laporte9140 points .
The content on this page is licensed under the terms of the Creative Commons Attribution-ShareAlike License.

Site Language

Reference Guide

Keywords

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



Tiki Newsletter

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