BoltWire is a content management system developed by Dan Vis.

Welcome Tour
Mailing List

Popular Posts

Version 5.11 Released
May 26, 2016

Big Changes Coming Soon...
April 28, 2016

Catching Up
April 6, 2016

Other Sites

Here's some other sites by Dan Vis:

Alexa Echoes
Join my adventures developing for Amazons exciting new voice platform.

Firefly Spot
Personal rambling about new gadgets, technology news, and space travel.

FAST Missions
My ministry hub, with news and updates about our online school.

You can follow him at www.danvis.info.


Documentation > Handbook > Conditions

Conditionals allow you to customize site content dynamically based on various criteria.

Here's a list of conditionals currently available in BoltWire. Click one for more info:


How to Use

Here is an example of how to use a conditional. It checks to see if the current user is logged in, and if so, gives them a welcome message.

[if login]Welcome {id}[if]

Here's how to use the "if / else" feature:

[if login]Welcome {id}[else]You are a Guest[if]

Some conditions require parameters:

[if more 7 5]True[if]

You can also use negation:

[if ! login]Please login to continue[if]

You can also use the operators && (and) and || (or). You can also use parentheses to form more complicated expressions:

[if login && mobile]Some mobile text for logged in users[if]

[if login && (more {var1} 10 || more {var2} 20)]Some text[if]

You can nest conditionals like this:

[if login][if admin]Logged in Admin[else]Logged in Member[if][else]Not logged in[if]

Note: Make sure you close all conditionals or it will cause problems with the display.

Conditions in search functions

Conditionals can be used in search and list functions as follows:

[(search group=member* if='between c {+p2} f')]

They can also be used when creating templates and formats for your search display.

Conditions in commands

There is an 'if' command that allows you to tap into the conditional engine through the forms processing engine. It is described in more detail in the commands tutorials, but here is a simple example:

[radio color red] Red   [radio color blue] Blue
[command if "equal {=color} red ? warn='Don't pick this one!'"]
[command warn]

This basically assigns a value to the warn command if you choose the red radio button. That causes the form to abort and the warning message is given. You can use any conditional with this command.

Order of operations

It is important to remember the order of operations when using conditionals with functions. The <(function)> markup is designed to process AFTER the conditionals, where as the other functions are processed BEFORE conditionals.

This means the first two examples will forward despite failing the conditional, because the function is processed before the conditional. The second one will work as expected:

[if false]{(forward some.page)}[if]
[if false][(forward some.page)][if]
[if false]<(forward some.page)>[if]

Similarly, the first two functions below will work as expected because the parameters are correctly supplied before the conditional is checked. The latter will not work properly, because the conditional is checked before the function value is retrieved.

[if equals {(function)} true]TRUE[if]
[if equals [(function)] true]TRUE[if]
[if equals <(function)> true]TRUE[if]

Even though both markups below will display properly, the first one wastes processing time. That is because while only the first search is shown, both searches are performed. The second one does the conditional first, and then only processes the correct search.

[if true][(search group=alpha)][else][(search group=beta)][if]
[if true]<(search group=alpha)>[else]<(search group=beta)>[if]


Toolmapping allows you to point a default conditional to a custom script, effectively overwriting the default behavior of the command. Suppose you wanted to customize how the time conditional works. Simply add the following line to index.php or config.php or a plugin, and when the conditional time is called, BoltWire will reroute the parameters to BOLTCmytime (your script), rather than BOLTCtime (the default script):

$BOLTtoolmap['c']['time'] = 'mytime';

It also works the opposite way. The following line would essential create a new "mytime" conditional that maps to the default time conditional and works exactly the same:

$BOLTtoolmap['c']['mytime'] = 'time';

Toolmapping is a very powerful feature for customizing how BoltWire works. BoltWire can also remap functions (change the 'c' to 'f') and commands (change the 'c' to 'x').

Developer Information

All the conditionals available to BoltWire are included in conditions.php and they are arranged in alphabetical order. There are several markup rules associated with conditionals in markup.php. And the functions that process the conditionals are found in library.php.

To develop a custom conditional simply create a function prefixed by BOLTC modeled on one similar to your needs. Then add it to the config.php file or a plugin. It then becomes instantly available to your site. The following php function allows you to use the markup below it.

function BOLTCfriday($args) {
     if (strftime('%A') == 'Friday') return true;

[if friday]Today is Friday[if]

If you create a custom conditional it can be combined with other conditionals and automatically inherits all the nesting, negation, and boolean capabilities of normal conditionals.

If it is an especially useful conditional consider posting it in the Solution Area at BoltWire so others can use your code.

To leave a comment, please login using your Facebook account: