{"id":9852,"date":"2009-10-26T14:09:30","date_gmt":"2009-10-26T18:09:30","guid":{"rendered":"https:\/\/www.bu.edu\/tech\/?page_id=9852"},"modified":"2013-03-08T16:06:03","modified_gmt":"2013-03-08T21:06:03","slug":"ponyexpress-templates","status":"publish","type":"page","link":"https:\/\/www.bu.edu\/tech\/services\/cccs\/websites\/people\/forms\/form-to-datafile\/ponyexpress-templates\/","title":{"rendered":"PonyExpress Templates"},"content":{"rendered":"<p>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.<\/p>\n<p>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, <strong>make sure you rename the file<\/strong> once it is on the server                 so that it does not have any three-letter extension (e.g., <code>.txt<\/code>).<\/p>\n<h2><a name=\"database\"><\/a>Simple database files<\/h2>\n<p>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.<\/p>\n<p>As of PonyExpress 2.1, outputting TAB-delimited files is quite                 simple and requires no templates. Simply adding a hidden field named                 &#8220;database&#8221; with a value of &#8220;yes&#8221; 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&#8217;s                 scripts to create a Web-searchable database.<\/p>\n<p>To specify the order of fields in your data file, use the hidden                 &#8220;order&#8221; tag. All fields listed in the value attribute of the &#8220;order&#8221; 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 &#8220;order&#8221; tag, as this allows you                 to specify the &#8220;primary key&#8221; used to sort the data on importing                 into a database.<\/p>\n<p>So, for example, after your existing hidden tags, you might add:<\/p>\n<p><code>&lt;input type=\"hidden\" name=\"database\" value=\"yes\"&gt;<br \/>\n&lt;input type=\"hidden\" name=\"datafile\" value=\"survey.txt\"&gt;<br \/>\n&lt;input type=\"hidden\" name=\"order\" value=\"lastname, firstname,                 email\"&gt;<\/code><\/p>\n<p>This would cause all data submitted to your form to be output into                 a TAB-delimited file named &#8220;survey.txt&#8221; located in the directory                 specified by your &#8220;form_location&#8221; variable. The &#8220;datafile&#8221; field                 is optional; by default the file would be named &#8220;datafile.txt&#8221;.                 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.<\/p>\n<p>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.<\/p>\n<p>Also, by default, the names of the fields are used to generate                 the first record, which serves as a special &#8220;header row.&#8221; This allows                 database programs to generate the column headers for you.<\/p>\n<p>So, an example data file would look something like this: <tt><\/tt><\/p>\n<p><tt>lastname firstname email comments grad_year phone<\/tt><\/p>\n<p><tt>Doby Jason jdoby@bu.edu Your form rocks! 97 358-9999<\/tt><\/p>\n<p><tt>Smith John qbert@bu.edu No comment. 99 555-5555<\/tt><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8230;<\/p>\n","protected":false},"author":1685,"featured_media":0,"parent":9813,"menu_order":2,"comment_status":"closed","ping_status":"open","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/pages\/9852"}],"collection":[{"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/users\/1685"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/comments?post=9852"}],"version-history":[{"count":4,"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/pages\/9852\/revisions"}],"predecessor-version":[{"id":63121,"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/pages\/9852\/revisions\/63121"}],"up":[{"embeddable":true,"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/pages\/9813"}],"wp:attachment":[{"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/media?parent=9852"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}