Skip Navigation

[Resolved] Conditional HTML Greater-Than opertaor

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 9 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 19:00 10:00 – 19:00 10:00 – 19:00 10:00 – 19:00 10:00 – 19:00 -
- - - - - - -

Supporter timezone: Europe/Madrid (GMT+01:00)

This topic contains 2 replies, has 2 voices.

Last updated by robD 9 years, 7 months ago.

Assisted by: Caridad.

Author
Posts
#240136
Screen Shot 2014-08-31 at 5.33.44 PM.png

Hello.

CPT: Games
Date Field: start-of-game
Custom Shortcode (registered on Views -> Setting page): currentdate

function currentdate(){
	return current_time('zHi');
}
add_shortcode('currentdate', 'currentdate');

Our Conditional statement:
[wpv-if gametime="[types field='start-of-game' style='text' format='YmdHi'][/types]" evaluate="$gametime > [currentdate]"]Game Over[/wpv-if]
Debug example:
Attributes: {"gametime":"201409061100","evaluate":"$gametime > 201408311722"}
Info: Conditional output: evaluated to false

Regardless of the 'currenttime', the $gametime is evaluating as less than 'currenttime' as it is a string of text.

If we do not use the argument and write the Conditional Statement as:
[wpv-if evaluate="[types field='start-of-game' style='text' format='YmdHi'][/types] < [currentdate]"]Game Over[/wpv-if]
Debug:
Attributes: {"evaluate":"201408301800 < 201408311735"}
Info: Conditional output: evaluated to true
Output: Game Over

It functions correctly (but seems wrong based on the quotes and apostrophes, see attachment). What is wrong with the args in the first Conditional Statement?

Thanks

#240215

Dear Rob,

You aren’t using the syntax correctly in the first instance, the correct way is:

[wpv-if gametime="wpcf-start-of-game" evaluate="$gametime > [currentdate]"]Game Over[/wpv-if]

But with this syntax you can’t control the format of the date.

In your second example you are doing it correctly.
Don’t worry about the quotes. The inner short codes are replaced first, which leaves the quotes correct for a second pass.

Please let me know if you are satisfied with my reply and any other questions you may have.

Regards,
Caridad

#240317

Thanks Caridad!

Perfect answer.

The forum ‘Types Community Support’ is closed to new topics and replies.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.