Knowledgebase



 Categories





 Dimofinf Mobile


Subscribe now to Dimofinf Mobile and enjoy a wide range of premium services. You will receive our SMS text messages wherever you are for a very low cost! More


 Currency Converter


  • Currency
  • US$ Amount

Modifiers functions



As it has been explained before in the variables tag, modifiers are functions that modify the variable value before printing it and you can write your own modifier function to use within the blocks by following these steps:

  • Create a file within the 'include/modifiers' folder using this name form 'modifier.name.php' where 'name' is the function name.
  • Write the following function formula in the function file:

function Dimofinf_modifier_name($params)

CODE :
function Dimofinf_modifier_name($params)
    {
    	$string = $params['string'];
	// the code 
	return $string;
    }

Where 'name' is the function name and '$params' is a matrix that includes the function parameters which are called when the modifier is called from within the block as every entry takes an index in the '$params' matrix and its value is the inserted value and it also includes the 'String' index which contains the variable value, noting that the function should return a value at the end where '$val' is an example for the reference value from the function. Please note that modifiers can be called several times for the same variable simultaneously.

      Helping modifiers which can be used in the blocks:

These are some useful modifiers which can help you with your programming and blocks:

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

This modifier is used to perform mathematical operations on the variable 'var' value.

 

Parameters:

  • sign (optional): the operation sign; '+' for addition, '-' for subtraction, '*' for multiplication and '/' for division.
  •  values (mandatory): the values the mathematical operations will be done on.

Example:

CODE :
{var|calc values="5,5,8" sign="+"|calc  values="1" sign="*"}

This modifier will perform the first mathematical operation by adding '5+5+8' then it will perform the second operation by multiplying the result of the first operation by '1'.

      {string|default value="value"}

This modifier is used to assign the default value in case the 'string' value is empty.

Parameters:

  • value (mandatory): the default value that will be assigned if the main variable value is empty.

Example:

CODE :
{title|default value="Dimofinf CMS"}

      {string|replace values="value_before,value_after"}

This modifier is used to replace words from the 'string' variable value.

Parameters:

  • values (mandatory): includes the value you want to replace and the word you want to replace it with; these two are separated by a comma.

Example:

CODE :
{string|replace values="hello,hello dimofinf"}

      {string|wordwrap length="90" break="n" cut="true"}

This modifier is used to break the sentence after a certain number of characters where the function 'wordwrap' is called from PHP.

Parameters:

  • length (mandatory): the number of characters after which the sentence is broken; moves to the next line.
  • break (optional): the division separator, it is '/n' by default.
  • cut (optional):when this is assigned to 'true', the division/breaking is forced. In other words, if you have a word is 8 characters and you set the sentence break at 4 characters, the word will be forced to break after 4 characters and won't be excluded because it is a connected word.

Example:

CODE :
{string|wordwrap length="10" break="<br>"}


Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read

$tpl object functions within the PHP file (Views: 428)

    - mk_template($var) This function is called to create a $tpl object as special $tpl...


Helping functions which can be used in the blocks (Views: 587)

      {function:alternate name="blockname" values="alt1,alt2"} This function is used to...


Block system tags within the block files & Variables, constants and general variables (Views: 637)

Block system tags within the block files: The blocks system has several tags that are placed in...


Blocks system (Views: 566)

Dimofinf offers you an exclusive state of the art blocks system through which you can separate...


Helping function used for blocks (Views: 551)

This is a set of helping functions which can be used in your programming for some ready parts...



Online