Workaround for subtracting in templates

Author Message

Felix Laate

Friday 29 February 2008 12:53:33 am

Hi all,

I'm tryning to do some subtracting i a template, i.e

$lastweek = sub($thisweek,1)

This returns a <i>Fatal error: Unsupported operand types</i>.

I found out from issues that there is an issue covering this: http://issues.ez.no/6607, which is supposed to be fixed at some time in the future.

Now I wonder if someone can think of a workaround?

Felix

Publlic Relations Manager
Greater Stavanger
www.greaterstavanger.com

Pascal Specht

Friday 29 February 2008 3:36:46 am

Hi Felix,

certainly $lastweek = add($thisweek,-1) won't work much better because $lastweek is probably not an integer...

What datatype is $lastweek ? If this is inside a module, you may perhaps get around the problem by calculating the value through the php code and using a template variable to get it back?
If $lastweek is a date/time and the operator hasn't been implemented in the template language, you probably will have to write a template operator for this. I always have a small module with useful stuff included in my install, so adding a template operator isn't much work...

</Pascal>

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 19 2025 15:13:57
Script start
Timing: Jan 19 2025 15:13:57
Module start 'layout'
Timing: Jan 19 2025 15:13:57
Module start 'content'
Timing: Jan 19 2025 15:13:58
Module end 'content'
Timing: Jan 19 2025 15:13:58
Script end

Main resources:

Total runtime0.6457 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.0046 589.2734152.6406
Module start 'layout' 0.00460.0022 741.914139.4766
Module start 'content' 0.00680.6378 781.3906529.5000
Module end 'content' 0.64460.0011 1,310.89068.1406
Script end 0.6457  1,319.0313 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00270.4179160.0002
Check MTime0.00110.1752160.0001
Mysql Total
Database connection0.00060.099910.0006
Mysqli_queries0.606893.9698540.0112
Looping result0.00040.0562520.0000
Template Total0.619896.020.3099
Template load0.00170.266020.0009
Template processing0.618195.723420.3090
Template load and register function0.00020.023710.0002
states
state_id_array0.00070.108910.0007
state_identifier_array0.00090.141620.0005
Override
Cache load0.00140.2230190.0001
Sytem overhead
Fetch class attribute can translate value0.00060.086020.0003
Fetch class attribute name0.00070.113940.0002
XML
Image XML parsing0.00210.319720.0010
class_abstraction
Instantiating content class attribute0.00000.000640.0000
General
dbfile0.00230.3491220.0001
String conversion0.00000.000640.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
2content/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
5content/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
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 14
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs