BoltWire

Innovative Ideas :: Radical Results!

INFORMATION

DOCUMENTATION

SOLUTIONS

Function Example

Documentation > Extending BoltWire > Function Example

Go here for basic information on functions. There's also info in the Developers Area? on functions.

Want to know how to define your own functions? If you know a little PHP it's easy. This page will focus on showing you how.

See the parent page for basics of how to create a BoltWire extension. Functions need to be in a config or plugin page. The first line of each file should be

<?php if (!defined('BOLTWIRE')) exit();

How to write and call a function


The name of the function must be "BOLTF" followed by your function name. This is the code of a very simple function called "hello":

<code>
function BOLTFhello($args, $zone) {
$greeting=$args['greeting'];
$name=$args['name'];
return "$greeting $name";
}
</code>

The parameters are received in the $args array, whose keys are the parameter labels.

Now your function is ready and you can call it in your pages:

<code>

</code>

If you prefer to omit the parameter labels and get the parameters by position, you have to write the function like this:

<code>
function BOLTFhelloagain($args, $zone) {
$greeting=$args[''][0];
$name=$args[''][1];
return "$greeting $name";
}
</code>

Then you can call the function this way:

<code>

</code>

Parameters in quotes


Quotes are mandatory when the paramaters have spaces. Otherwise they are optional. You can use single or double quotes. Examples:

<code>


</code>

Copyright © 2013, all rights reserved.