Xataface HTML Reports Module 0.2
HTML Reports Module for Xataface
Adding Dynamic Fields to a Template
See also:
Getting Started

In the previous example we created a rather useless report template. It does nothing except print "Hello World" once for each record in a found set. In this section we'll expand on this example to turn out report into something a little bit more useful.

Placeholder Macros

Before getting into the features of the WYSIWYG editor, let's take a quick look at how the report generator parses fields embedded in templates.

Suppose you have a field named first_name in the table that is the subject of a report. Then you can embed the value of the first_name field into a report by adding {$first_name} to the template. E.g.

<p>First Name: {$first_name}</p>

would be rendered as

<p>First Name: Steve</p>

when run on a record whose first_name field contained the value "Steve".

In order to assist you in creating your templates, the HTML Reports module includes a field browser that allows you to browse through the fields in your table and add them to your template by selecting them with your mouse. Read on for details on how to add fields using this method.

Using the WYSIWYG Editor To Insert A Field

Selecting A Table

The Tablename dropdown list on the report form allows us to specify the table on which this report is meant to run. In my particular case, I'm going to create a report to run on my Tools table. You can select any table you like for your example.

Inserting a Field

We left off the last example with a nearly blank template with only the text "Hello World". Now we're going to change it slightly. I Want the template to say "Hello {$tool_name}" where {$tool_name} is the name of a tool. When the report is run on a set of tool records, I want to to have one line per tool in the found set.

Steps:

  1. Click the cursor inside the HTML editor, and delete the text "World", so that it only says "Hello" now. Make sure that text carat is placed just after "World ".
  2. Click the Insert Field button in the editor toolbar.
    Screen_shot_2011-08-10_at_11.32.20_AM.png?max_width=640
    This will open up a field browser dialog box as a tree widget.
    Screen_shot_2011-08-10_at_11.33.39_AM.png?max_width=640
    Expand the Fields node to reveal the fields that are available to add to your template.
    Screen_shot_2011-08-10_at_11.33.47_AM.png?max_width=640
    Click on a field to add it to your template. You should see a text placeholder for that field show up in your template.
    Screen_shot_2011-08-10_at_4.01.51_PM.png?max_width=640
  3. Click the Preview Report button in the editor toolbar again so see what our report looks like now. Now you should see the value of the field that you added written for each of the first 10 records in the table.
    Screen_shot_2011-08-10_at_11.35.49_AM-1.png?max_width=640

Exercise

Try adding some more fields to your template and then preview it. See how "useful" you can make it look

What's Next

We still haven't saved our template. We'll finally get a chance to do that in the next section: Publishing Reports for Other Users

See also:
Getting Started
 All Data Structures Files Functions Variables Enumerations