TinyButStrong - the PHP Template Engine
Categories > OpenTBS general >

Feature request: operations on fields

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs

By: Walter
Date: 2014-09-08
Time: 16:17

Feature request: operations on fields

Hello,

I know it is not possible with normal tags, and sometimes it is possible with onData, but what I want to achieve is mathematical operations with both operands variables

[block1:block=start]

value=[block1:num] equal to [block1:num;ope=div:[value2]]

[block1:block=end]

As you can see.. [block1:num;ope=div:[value2]]

By: Skrol29
Date: 2014-09-08
Time: 18:10

Re: Feature request: operations on fields

Hello Walter,

It seems to can easily achieve this using the parameter "onformat".

Simple example:

PHP:
function f_format_div($FieldName,&$CurrVal,&$CurrPrm) {
   $CurrVal = $CurrVal / $CurrPrm['value2'];
}

Template:
[block1:block=begin]

value=[block1.num] equal to [block1.num;onformat=f_format_div;value2=29]

[block1:block=end]