Inconsistent if statement behaviour

Inconsistent if statement behaviour

Tuesday 29 July 2008 10:37:21 am - 3 replies

Author Message

James Ward

Tuesday 29 July 2008 10:39:25 am

Whoops. Accidently cut and pasted some of my testing code. Here is the original code which works fine in my html template but breaks in a pdf template:

{if and(ne($event.data_map.start_date.content.timestamp,$event.data_map.end_date.content.timestamp),$event.data_map.end_date.has_content)}
 {def $event_date = concat($event.data_map.start_date.content.timestamp|datetime( 'custom', '%M %d, %Y' ),' - ',$event.data_map.end_date.content.timestamp|datetime( 'custom', '%M %d, %Y' ))}
{else}
 {def $event_date = $event.data_map.start_date.content.timestamp|datetime( 'custom', '%M %d, %Y' )}
{/if}

working at www.wardnet.com
blogging at www.jamesward.ca

James Ward

Tuesday 29 July 2008 10:59:52 am

Looking at it more closely I guess the problem would be better described as inconsistent has_content behavior. The other part of my if statement works fine, it shows just the start date if the two dates are equal. Unfortunately it tries to show both dates when the end date has no content.

working at www.wardnet.com
blogging at www.jamesward.ca

Ivo Lukac

Tuesday 29 July 2008 11:21:24 pm

Hi James,

In my experience there is no unique way to check if attribute has content. For date I would use data_int:
{$event.data_map.end_date.data_int}

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

You must be logged in to post messages in this topic!

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