BoltWire is a FREE content management system written in PHP.

Its innovative architecture combined with best-in-class forms processing makes it ideal for creating complex, interactive, web applications fast...




Handbook > Variables > Data Variables

Data variables are stored on a specific page, in a section of that page not visible when viewing or editing the page. The values are saved and edited using the data action or a custom form.

Their syntax is similar to system variables except there is one colon at the beginning to indicate it is a data variable:

{:field}variable from the current page
{page:field}variable from the specified page

Note: There is a special shortcut for retrieving data from a users member page. Use {~field} for the current user, and {~id:field} for another user. These are equivalent to {member.{id}:field} and {member.some_id:field} respectively.

Note: The data variable {:title} is a special variable that functions as a data variable when a title is set, and like a system variable (using the last part of the page name) when a title is not set. It is exactly equivalent to the system variable {title}.

Data Parts
Data Vars can actually contain multiple bits of information, and it is possible to retrieve specific pieces as desired. Suppose you saved "field1" with the following value:

part1 | another part | still more | the last part

The individual parts can be retrieved using the following syntax:

{:field1:1}   part1
{:field1:2}   another part
{:field1:3}   still more
{:field1:4}   the last part...

The list of data variables assigned to a page is returned by the {data} system variable.

Security and Data

Some variables need to be protected so several layers of security are built into BoltWire.

1) Data on a page you are not authorized to read is not retrievable.
2) To write data to a page, you must have write permissions. To bypass this, set "dataAuth: false" in site.config.
3) The page allows you to restrict access to specific data fields further to specific users or groups. By default, passwords are only visible to owners and emails to admin and owners.

You can fully customize the authorizations page anyway you wish.

Working with Data Variables

To store a data value on a page, go to the page and click the data action. At the bottom of the action page, there is a text box where you can enter new data fields. A data variable must be a single word, consisting of letters, numbers hyphens or underscores. You can create multiple data fields at one time by entering a comma separated list of fields, like field1,field2,field3.

Click "NEW FIELDS" and you will see text boxes you can now use to save values for those fields. You can enter any value you want--from single letters or numbers to links, whole sentences, or markup. Click SAVE and the data variable will be securely stored on the page.

To retrieve the values put {:field1}, {:field2}, and {:field3} on the page. The values you entered will be retrieved.

Let's say you stored the data on You can also insert it into by entering {}, {}, and {} on that page.

If a data variable is not found, a blank value will be returned.

To delete a data variable, go to the data action and delete the value beside the field name. Click save and the data variable will be fully deleted from the page. It will no longer show up in the {data} system variable or the data action. You can recreate it again at any time.

Using Forms

For more information about creating forms, please see the forms tutorial. For a quick overview of how easy it is to create your own custom data forms, keep reading.

Suppose you wanted to collect various information from your users and store it on their member pages. Try using a form like this:

Display Name: [text title "{~title}"]
Email: [text email "{~email}"]
Phone: [text phone "{~phone}"]
Country: [text country "{~country}"]
[submit SAVE]
[command savedata title,email,phone,country page=member.{id}]

Line 1 introduces the form. Line 2-5 provide input fields for for data fields. Each first pulls in any existing values for the current user. The next line submits the form. The next line tells BoltWire to save the four data fields to the users member page. And the last line closes the form. Don't forget this line!

Generating Reports

Suppose you have 100 users and a phone number for each of them--and you want to generate a phone list. It's very simple in BoltWire. Try the following markup:

[(search group=member template='[r][c]{+:title} [c]{+:phone}' table=true count=false)]

The '+' in the template means draw the data information from each page generated by the search function, rather than the current page. The output will be formatted in a simple two-column table. The count parameter means it will show all available names, rather than stop at the default first 50 matches. Obviously you can polish up the template any way you wish.

If you have a large number of members, you may wish to consider creating an index page with all the telephone numbers and generate a report using info variables. Reports from an index page are much faster because BoltWire only has to open one page rather than open and close multiple pages and extract one bit of data from each.

There are many more things you can do with BoltWire and data. You could for example, populate whole groups of pages by simply retrieving data values from the various pages and format the information for display using a single header or footer. You could then create a link to a simple action page that allows users to update the data values on those pages using a form like the one above. This approach makes it a snap to turn any group of pages into structured records and then generate dynamic reports any way you want. Hopefully this brief intro is enough to get you started!