Forums / Setup & design / Substract: A=B-C... or: how does the sub-operator work?

Substract: A=B-C... or: how does the sub-operator work?

Author Message

Marco Zinn

Friday 24 October 2003 11:58:23 am

I need to do some calculations in a template (pagelayout.tpl), like this pseudo-code:
level=$node.path.depth (not correct, but you get the point)
span1=level+1
if span1>10 then span1=10
span2=10-span2

As you might imagine, this will be used for two column-spans in a table, which has 10 columns.
I even have a problem with the first assignement. I tried
{let level=$the_variable_name}
but even that did not work. Is "level" a reserved word?
For the other lines, I will need the "inc", "min" and "sub" operators (from http://ez.no/developer/ez_publish_3/documentation/development/libraries/ez_template/operators/arithmetics), but I don't know, how to use them for the calculations I need.
Any code-hint (or working example code-snippet) is highly appreciated!
TIA

Marco
http://www.hyperroad-design.com

Vivienne van Velzen

Monday 27 October 2003 12:57:39 am

Hi Marco,

I tried the following, and it worked for me.

{let level=count($node.path_array)
     span1=min($level|inc(), 10)
     span2=sub(10,$span1)
}
{$level}<br>
{$span1}<br>
{$span2}
{/let}

I didn't have any trouble using 'level' as variable name. Maybe it's a namespace issue? Hope this helps,

Vivienne