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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 31 2025 10:10:04
Script start
Timing: Jan 31 2025 10:10:04
Module start 'layout'
Timing: Jan 31 2025 10:10:04
Module start 'content'
Timing: Jan 31 2025 10:10:05
Module end 'content'
Timing: Jan 31 2025 10:10:05
Script end

Main resources:

Total runtime1.0739 sec
Peak memory usage4,096.0000 KB
Database Queries54

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0040 588.2813151.2266
Module start 'layout' 0.00400.0020 739.507836.6797
Module start 'content' 0.00591.0669 776.1875920.3906
Module end 'content' 1.07280.0010 1,696.57817.8125
Script end 1.0739  1,704.3906 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00280.2652160.0002
Check MTime0.00120.1140160.0001
Mysql Total
Database connection0.00050.050310.0005
Mysqli_queries1.026795.6080540.0190
Looping result0.00050.0454520.0000
Template Total1.041997.020.5209
Template load0.00210.191020.0010
Template processing1.039896.823520.5199
Template load and register function0.00120.114710.0012
states
state_id_array0.00280.262810.0028
state_identifier_array0.00100.097020.0005
Override
Cache load0.00170.1561220.0001
Sytem overhead
Fetch class attribute can translate value0.00050.048720.0003
Fetch class attribute name0.00200.189130.0007
XML
Image XML parsing0.00180.168520.0009
class_abstraction
Instantiating content class attribute0.00000.000630.0000
General
dbfile0.00410.3772160.0003
String conversion0.00000.000440.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
4content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 12
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs