Nuts & bolts | Geek
VITES™ Response Engine
The Response Engine receives instructions from the Rules Engine, via ATC, and delivers an appropriate response, which is usually a web "page" for Apache to send to the browser.
Based on the (name of the) content and profile passed from the Rules Engine, the Response Engine hunts through the Response Pool, which is a collection of templates either as a flat file system or a database, and collates the appropriate templates, populates them with the appropriate data and sends the collated and populated response back to ATC.
In addition to the "substitution" approach of standard templating systems (i.e. swap tag <VITES var="data.forename" /> for the visitor's forename), the content of the response is personalised in two dimensions: by "depth" according to the VITES™ Profile and by "progress in time" as dictated by the Data Capture placeholder system.
For more details on how the appropriate, personalised content for the individual visitor is picked see VITES™ Profiles, VITES™ Templates: Tags and VITES™ Templates: Data Capture.
VITES™ Templates: Tags
At the most basic level, content served back to the visitor can be customised using the tools available in pretty much any templating system: placeholders that are swapped with the contents of a variable or file. (We are assessing the benefit of switching to a more fully-featuring approach such as HTML::Mason that would give even greater control to the template creator – embedded code etc.).
The <VITES> tag is used with different attributes in the HTML templates to dictate how data is substituted:
<p>Welcome back, <VITES var="data.forename" /></p>
<VITES include="some-extra-stuff" />
<!-- the contents of ./<profile>/includes/some-extra-stuff.[html|css|js|txt] -->
<VITES is_true="data.is_winter">
<p>Brrr... it's cold outside!</p> <!-- show only in winter -->
</VITES>
<!-- also is_false="data.some_var" -->
VITES™ Templates: Data Capture
One dimension (the "depth") of personalised content is handled by the VITES™ Profile. The second dimension, "progress", can be addressed using the Data Capture (DC) control of the templating system. (It can also be addressed by using profiles if you prefer).
The VITES™ Profile is intended to dictate content based on "what we know about you". The DC is intended to dictate content based on "your whereabouts in the communication cycle with us". In practice the distinction is often very blurred!
Imagine a very (overly!) simple example: you run a site that canvasses opinion on the latest widget. Your initial target is to get the visitor to answer a series of questions about the widget. Once they have done so, you would like them to continue to give you email addresses of their friends who might be interested in opining on the virtues of said widget.
You have a web-site of 5 pages, and, of course (!), because the questionnaire is the very reason for the existence of the site, you have this short, HTML form in one position or another on every page. Once the questionnaire form has been completed, you would like it to be replaced everywhere it exists on the site with the "recommend-a-friend" form. You can either create two copies of each page and give yourself a maintenance headache or use some kind of placeholder to indicate where the form should go and replace it with the appropriate one. This is exactly what the DC does and, at least in our opinion, in rather a nice way!
First you define the data capture point(s) in your templates:
<VITES data_capture="1" />
Then you create your forms in separate include files, remembering to include a VITES™ completion_var: this is what VITES™ will use to decide which form to show:
<!-- ./<profile>/data_capture/questionnaire-form.html -->
<VITES priority="1" completion_var="data.dc_finished_questionnaire" />
<!-- questionnaire form goes here -->
<!-- ./<profile>/data_capture/refer-a-friend-form.html -->
<VITES priority="2" completion_var="data.dc_finished_recommending" />
<!-- refer a friend form goes here -->
In VITES™ Functions, which see, you define a function that emails you the answers when the questionnaire form is submitted. This function, on successful completion, will also set the DC completion var "data.dc_finished_questionnaire" to "true" (or 1 or "yeeehaaa!" or anything else that evaluates to true in Perl).
The VITES™ Response Engine will insert the highest priority (lowest number) data capture include, whose completion var is not true, into the highest priority (lowest number) data capture placeholder in the template. (Note: we are only using one data capture point on our pages in this example; you can use as many as you like as long as you can cope with the logic!).
Finally, because we want the "recommend-a-friend" form to loop forever (i.e. be shown to the visitor on every page, every time they view a page or return to the site no matter how many friends they have already recommended), we decide never to set the completion_var to true in the function that handles this form.