In order to format emails or web pages created by PonyExpress, you will create separate template files. There are two types of templates used with PonyExpress: email templates and file templates.
All the templates are plain text files, so if you create them in more advanced word processors like Microsoft Word, make sure to save them as plain text. Also, since Windows applications may append file extensions invisibly, make sure you rename the file once it is on the server so that it does not have any three-letter extension (e.g., .txt
).
Simple database files
Almost all database/spreadsheet software can read a simple file type called a TAB-delimited file. This is simply a collection of single-line records in which the fields are separated by TAB characters.
As of PonyExpress 2.1, outputting TAB-delimited files is quite simple and requires no templates. Simply adding a hidden field named “database” with a value of “yes” will cause PonyExpress to write a TAB-delimited file which you can then import into database programs like Access or FileMaker, or even use in conjunction with UIS’s scripts to create a Web-searchable database.
To specify the order of fields in your data file, use the hidden “order” tag. All fields listed in the value attribute of the “order” tag will be output first in that order; any fields not specified this way will be output alphabetically as the rest of the record. It is a good idea to include at least one or two fields in an “order” tag, as this allows you to specify the “primary key” used to sort the data on importing into a database.
So, for example, after your existing hidden tags, you might add:
<input type="hidden" name="database" value="yes">
<input type="hidden" name="datafile" value="survey.txt">
<input type="hidden" name="order" value="lastname, firstname, email">
This would cause all data submitted to your form to be output into a TAB-delimited file named “survey.txt” located in the directory specified by your “form_location” variable. The “datafile” field is optional; by default the file would be named “datafile.txt”. Within this output file, each new record will begin with the lastname, firstname, and email fields followed by the remaining fields from the form in alphabetical order.
In addition, if you will want to import the data from your datafile into a spreadsheet application, such as Microsoft Excel, use the order tag, with each field name specified in the value attribute. This will ensure that the proper number of tab characters are inserted, even if visitors to your form leave some fields blank. This is especially useful for checkboxes, where visitors to your form may select different numbers of them.
Also, by default, the names of the fields are used to generate the first record, which serves as a special “header row.” This allows database programs to generate the column headers for you.
So, an example data file would look something like this:
lastname firstname email comments grad_year phone
Doby Jason jdoby@bu.edu Your form rocks! 97 358-9999
Smith John qbert@bu.edu No comment. 99 555-5555