Welcome Tour
Site Checklist
Our Story




This command/function taps into BoltWire's info processing capabilities which allows you to store and retrieve information in database like ways.

The page parameter in this function can take page shortcuts. It is also smart enough to take UTF page names and make the appropriate connections. If the page is not specified, it defaults to the current page.

Retrieving Info Vars

Suppose you have an info page with the following content about various users (their favorite color, fruit, and country). We'll call this page info.users.

bob: blue | banana | Spain
sue: red | apple | England
jane: green | mango | Germany
dave: yellow | cherry | Italy

To retrieve an info var value as a function, simply supply the page and the field:

[(info field=bob page=info.users)]
This displays: blue | banana | Spain

To retrieve a specific part, just identify it:

[(info field=bob page=info.users part=3)]
This displays: Spain

Note: You could also simply do {info.users::bob} or {info.users::bob::3} to get the same results.

With a form I can make this interactive, allowing the user to select the person whose info they want to retrieve, and even the part. For example:

Choose a user: [radio user bob] Bob   [radio user sue] Sue   [radio user jane] Jane   [radio user dave] Dave
Get favorite: [radio which 1] Color   [radio which 2] Fruit   [radio which 3] Country
[command info page=info.users field={=user} part={=which}]
[command passdata info]

Info Requested: {?info}

This form allows the user to select a field and part, then retrieves the requested information. Passdata sends the content of the info command to the next page as a get variable where it is displayed.

This interactivity is one advantage of the info command over the info function.

For an info variable to be retrieved, the user must have view permissions.

If no information is found a blank is return unless the default parameter is set. In the latter case the default value will be returned.

[(info field=mary page=info.users part=3 default='Info not found')]
This displays: Info not found

Storing Info Vars

You can also use the info command (and function) to set an info var value. If I want to allow a user to update their country of residence I could use this form:

Country: [text country '{info.users::{id}::3}']
[command info page=info.users field={id} part=3 value={=country}]

This retrieves the user's current country and allows them to edit it. Submit the form and their country gets updated. We could let them change all three on a single form like this:

Color: [text color '{info.users::{id}::1}']
Fruit: [text fruit '{info.users::{id}::2}']
Country: [text country '{info.users::{id}::3}']
[command info page=info.users field={id} value='{=color} | {=fruit} | {=country}']

Here, they can edit any of the three fields. Note how their data parts are assembled together and then the entire info var is saved.

If the info var value is a comma separated list, info can tap into BoltWire's csv processing capabilities. To add an item, set the value to +item. To remove an item, set it to -item. You can even combine several of each. Here's an example using the info function:

[(info page=info.friends field=bob value=+mark,-dave)]

This will add mark and drop dave from bob's friend list. That is

bob: sue,jane,dave

will become

bob: sue,jane,mark

Using this technique, you could keep a friends list for every member of your site all on one page, and allow users to update their list when they want. Because the information is on one page, you can do lightning fast searches and reports.

For an info var to be overwritten the user must have either write permission or info permission. This means you can give users the ability to set info vars on certain pages without having the ability to edit those pages directly. Info permissions are controlled by, and write permissions are controlled by site.auth.write. See the tutorial on permissions for more details.

Info Processors

In addition to saving and retrieving info vars, the info command/function can call various info processors--to perform special actions. The following are built into BoltWire. For brevity, their syntax will be demonstrated as functions:

[(info exists field=bob]
Returns true if field exists on page (even if the value is blank). False if it doesn't.

[(info list]
Returns a csv list of all the fields on page.

[(info delete field=bob]
Deletes the entire line, both field and value. Requires write permission.

[(info count]
Returns a count of how many fields are on the page.

[(info sum]
Adds up the numeric values of fields on the page. Set part=2 to sum up the part 2's.

[(info find value='some text']
Returns field with specified value if it exists.

[(info prev field=bob]
Returns the field just before bob if it exists.

[(info next field=bob]
Returns the field just after bob if it exists.

[(info first]
Returns the first field on the page.

[(info last]
Returns the last field on the page.

[(info counter page=info.counter)]
Adds 1 to the value of the specified field on page info.counter.

Custom Info Processors

Suppose you wanted to create a custom info processor called tags. It's easy. Simply create a custom PHP script that looks like the following and place it in your config.php file or a plugin.

function BOLTinfoTags($info, $args, $page) {
      Your code here

Then call the processor using this syntax: [(info tags...)].

The $info variable is the array of all field-value pairs on the page, $args are any parameters passed to the original command or function, and $page is the page being used.

Create the extension, and it is immediately integrated into BoltWire's full info processing system.


Suppose you create an info function to serve as a page counter for your forum group, but do not want to count views of the header or footer file. You can put the function in forum.footer and set the exclude parameter to ignore any pages you specify. I also may want to supress the output:

[(info counter page=info.counter field={p} exclude=forum,forum.header,forum,footer output=false)]