Actions

Difference between revisions of "Theme editor - Available Twig functions"

From LimeSurvey Manual

(Page create)
 
(Update page)
Line 1: Line 1:
= Twig included function =
+
= Php included function =
  
= Specific function for twig
+
* [http://php.net/array-flip array_flip]
 +
* [http://php.net/array_intersect_key array_intersect_key]
 +
* [http://php.net/str_replace str_replace]
 +
* [http://php.net/intval intval]
 +
* [http://php.net/empty empty]
 +
* [http://php.net/reset reset]
 +
* [http://php.net/in_array in_array]
 +
* [http://php.net/array_search array_search]
 +
* [http://php.net/isset isset]
 +
* [http://php.net/sprintf sprintf]
 +
 
 +
= Specific function for LimeSurvey =
 +
 
 +
== processString ==
 +
 
 +
Process Expression Manager with any string with current page information, return a string.
 +
Parameters are
 +
* the string to be processed
 +
* a boolean : return static string (or not), default to no.
 +
* an integer : recursion (max) level to do, default to 3
 +
* an array of string: replacement out of current expression know vars. The jey is the value to be replaced, the value is the replacement.
 +
 
 +
== getAllAnswers ==
 +
 
 +
Return an array with all current response of the survey in parameters.
 +
Parameters are
 +
* The surveId to get response
  
 
= Adding a function =
 
= Adding a function =
 +
 +
You can add any PHP existing function easily in your config.php file. This is done adding the function in twigRenderer.
 +
 +
<syntaxhighlight lang="php" enclose="pre">
 +
'twigRenderer' => array(
 +
'functions' => array(
 +
'strlen' => 'strlen',
 +
),
 +
'sandboxConfig' => array(
 +
'functions' => array(
 +
'strlen',
 +
),
 +
),
 +
),
 +
</syntaxhighlight>

Revision as of 08:47, 27 February 2019

Php included function

Specific function for LimeSurvey

processString

Process Expression Manager with any string with current page information, return a string. Parameters are

  • the string to be processed
  • a boolean : return static string (or not), default to no.
  • an integer : recursion (max) level to do, default to 3
  • an array of string: replacement out of current expression know vars. The jey is the value to be replaced, the value is the replacement.

getAllAnswers

Return an array with all current response of the survey in parameters. Parameters are

  • The surveId to get response

Adding a function

You can add any PHP existing function easily in your config.php file. This is done adding the function in twigRenderer.

		'twigRenderer' => array(
			'functions' => array(
				'strlen' => 'strlen',
			),
			'sandboxConfig' => array(
				'functions' => array(
					'strlen',
				),
			),
		),