Conditional Mental Trauma for Comparing if Same Date
Posted: 16 May 2008 12:46 PM   [ Ignore ]  
Lab Assistant
Avatar
RankRank
Total Posts:  157
Joined  09-06-2006

I’m making an event listing and trying to compare 2 custom date fields. One is for event start (event_start), the other for end(event_end). What I’m trying to do is compare the value to see if they are the same day and if so to change the event_end formatting to omit the day and date. I have this but it’s probably not even close:

{if event_start == "%z" AND event_end == "%z"}–
{event_end format="%g:%i%a"}{if:else}{event_end format="%l %F %d, %Y %g:%i%a"}{/if}

I couldn’t find a reference for comparing the value of two fields in the documentation and I figure the date thing is making it more complex.

Thanks.

 Signature 

Kyle Summer | smartpill design | New Haven, CT

Profile
 
 
Posted: 16 May 2008 01:26 PM   [ Ignore ]   [ # 1 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15368
Joined  05-15-2004
smartpill - 16 May 2008 12:46 PM

What I’m trying to do is compare the value to see if they are the same day and if so to change the event_end formatting to omit the day and date.

{if event_start == "%z" AND event_end == "%z"}–
{event_end format="%g:%i%a"}{if:else}{event_end format="%l %F %d, %Y %g:%i%a"}{/if}

Well, somewhat close… both event_start and event_end are custom date fields, right? In that case, try something like this:

{if '{event_start format="%z"}' == '{event_end format="%z"}'}

Normally it’s not recommend to put EE variables in quotes, but I am not sure there is another way here. Well, apart from PHP, obviously.

Moved to Howto.

 Signature 

Everything will be good in the end. If it’s not good, it’s not the end.

Profile
MSG
 
 
Posted: 16 May 2008 01:37 PM   [ Ignore ]   [ # 2 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  157
Joined  09-06-2006

Thanks, I replaced the code but for some reason I’m getting this error now:

Parse error: syntax error, unexpected '}' in /www/.../public_html/.../core/core.functions.php(637) : eval()'d code on line 7

 Signature 

Kyle Summer | smartpill design | New Haven, CT

Profile
 
 
Posted: 16 May 2008 01:41 PM   [ Ignore ]   [ # 3 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15368
Joined  05-15-2004

Are you using PHP on this page?

 Signature 

Everything will be good in the end. If it’s not good, it’s not the end.

Profile
MSG
 
 
Posted: 16 May 2008 01:46 PM   [ Ignore ]   [ # 4 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  157
Joined  09-06-2006

Yes, PHP on output. Also, I saw it should have been:

{if '{event_start format="%z"}' == '{event_end == "%z"}' } –{event_end format="%g:%i%a"}{if:else}{event_end format="%l %F %d, %Y %g:%i%a"}{/if}

where you had event_end compared to itself.

I’m still getting an error, but now it says:

Parse error: syntax error, unexpected T_IS_EQUAL in /www/.../public_html/.../core/core.functions.php(637) : eval()'d code on line 7

Would PHP being on be causing this?

 Signature 

Kyle Summer | smartpill design | New Haven, CT

Profile
 
 
Posted: 16 May 2008 01:48 PM   [ Ignore ]   [ # 5 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15368
Joined  05-15-2004

Duh, my mistake, please try again. The correct code should’ve been:

{if '{event_start format="%z"}' == '{event_end format="%z"}'}

 Signature 

Everything will be good in the end. If it’s not good, it’s not the end.

Profile
MSG
 
 
Posted: 16 May 2008 02:03 PM   [ Ignore ]   [ # 6 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  157
Joined  09-06-2006

Perfect! If anybody wants the final code, it is:

{event_start format="%l %F %d, %Y %g:%i%a"} {if event_end}{if '{event_start format="%z"}' == '{event_end format="%z"}'}– {event_end format="%g:%i%a"}{if:else}– {event_end format="%l %F %d, %Y %g:%i%a"}{/if}{/if}

Thanks so much!

 Signature 

Kyle Summer | smartpill design | New Haven, CT

Profile
 
 
Posted: 16 May 2008 02:05 PM   [ Ignore ]   [ # 7 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15368
Joined  05-15-2004

My pleasure smile

 Signature 

Everything will be good in the end. If it’s not good, it’s not the end.

Profile
MSG
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 64909 Total Logged-in Users: 43
Total Topics: 81853 Total Anonymous Users: 31
Total Replies: 440066 Total Guests: 236
Total Posts: 521919    
Members ( View Memberlist )