custom Template field shortcuts

Explain how to add own template field shortcuts, like $[Now] etc. So you can quickly add your own functions into any template field.

Create a file <customname>.inc.php in the folder modules/Workflow2/extends/shortfunctions/

This files don’t must follow any structure, but we would recommend, to bundle your functions within a class to prevent duplicate function names.

We recommend the following structure:

<?php
class CustomClassName {

    public static function functionname($context, $parameters ...) {
        
        return $returnValue;
    }

}
\Workflow\Shortfunctions::register('shortcut', array('CustomClassName', 'functionname'));

The only requirement is, you call the

\Workflow\Shortfunctions::register

function, with shortfunction as first parameter and the php callback as second parameter. An optional third parameter as boolean could be set to false, to prevent parsing of parameters, so you get $fieldname instead of the value of the field called “fieldname”

To use this defined shortcut, use $[shortcut]

As example you could take a look on core.inc.php file, within this extension directory.

Artikel-PDF herunterladen