Functions of Modifiers

Brief: as previously clarified in the variants tag, the modifiers are the functions that edit the variant value before being printed. You can enter your modifier function to be used in the block following the below steps: 

1- create a file in (include/modifiers) folder using the name format “modifier.name.php, as “name” is the given name of the modifier. 

2-  add the below form to the modifier file

[code] functionDimofinf_modifier_name($params){ $string = $params['string']; //code return $string; } [/code]

“Name“ is the given name to the function, while  “$params” is a matrix that includes the functions parameters that are recalled from the block along with the modifier. The entrance has an index in the $params matrix and its value is the entered one, it also includes a String index that consists of the variant value. Noting that the function has to return “value” at the end as $val is an example of the function returned value. The modifiers might be recalled more than once for the same variant at the same time. 

 

Assistive modifiers that can be used in blocks: 

Hereunder, some useful modifiers that can help in programming and blocks: 

- {var|calc values="5,5,8"sign="+"}

This modifier is used in calculation of the variant value (Var_. 

Parameters: 

Sign (optional) a sign of the calculation: + (plus), (-) minus, (* )multiply, (/) division

Values (mandatory): values that are calculated. 

 

Example: 

CODE :

This modifier calculated 8+5+5, then calculate the output by “1” 

- {string|defaultvalue="value"}

This modifier is used to set a default value in case the variant value is empty string

Parameters: 

Value (obligatory): the default value that is set in case the main variant value is blank. 

 

Example: 

CODE :

- {string|replacevalues="value_before,value_after"}

This modifier is used to replace terms of the variant value (string). 

Parameters: 

Values (obligatory): consists of replaced value and terms using a comma between them. 

 

Example: 

CODE :

- {string|wordwraplength="90"break="n"cut="true"}

This modifier is used to divide the sentence after a certain number of characters, as it recalls the (wordwrap) function from PHP.

Parameters: 

Length (mandatory): the number of characters after which the sentence is divided. 

Break (optional): division break (,) default (.n). 

Cut (Optional) if you mark (true), the division will be automatically done, for example, if there is a word that consists of 8 characters, and you set the division to be after 4 characters, the word will be obligatory divided into two parts. 

Example: 

CODE :



Was this answer helpful? 0 Users Found This Useful (0 Votes)