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.