Skip Navigation

[Resolved] Conditional Block and comparing to date/time fields for the same day.

This thread is resolved. Here is a description of the problem and solution.

Problem:

Setup Toolset conditional block using Types shortcode.

Solution:

Here are some tips:

Within shortcode [types ...][/types], use the double quotes

outside shortcode [types ...][/types], use the single quote.

For example:

https://toolset.com/forums/topic/conditional-block-and-comparing-to-date-time-fields-for-the-same-day/#post-1770207

Relevant Documentation:

This support ticket is created 4 years, 4 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 4 replies, has 2 voices.

Last updated by Jonathon Hanten 4 years, 4 months ago.

Assisted by: Luo Yang.

Author
Posts
#1769725

Tell us what you are trying to do? I am trying to dates for an event two different ways depending on if the start date/time and end date/time are on the same day or multiple days. For example if an event is has a start date of January 1, 2020 at 10:00 am and an end date of January 1, 2020 1:00pm I would want the content template to show: January 1, 2020 10:00 am - 1:00pm. However if an event is say on January 1, 2020 10:00 am and goes until January 3, 2020 at 10:00 am I would want the template to show January 1, 2020 10:00 am - January 3, 2020 10:00 am.

Is there any documentation that you are following? All the documentation I have found on your website is for views and not the block editor. It doesn't appear that I can use shortcodes inside the conditional block of gutenberg.

Is there a similar example that we can see?

I found the following on your website: '[types field='startdate' style='text' format='F, d'][/types]' eq '[types field='enddate' style='text' format='F, d'][/types]' but again I couldn't save that in the conditional block it seems to only use $(wpcf_startdate)

What is the link to your site?

hidden link. - Single day example
hidden link - Multiple Day example

I'm sure there has to be a way to do this it seems like such an easy/common problem.

#1769733

Sorry i forgot to mention taht I found this: https://toolset.com/forums/topic/conditional-output-related-to-date-fields/ but again it doesn't seem to relate to the new block method.

#1770207

Hello,

Please try to modify your codes as below:

  ( '[types field="startdate" style="text" format="F, d"][/types]' eq '[types field="enddate" style="text" format="F, d"][/types]' ) 

Tip:
Within shortcode [types ...][/types], use the double quotes
outside shortcode [types ...][/types], use the single quote.

#1770791

When I do as you recommended the Conditional block reports that the condition is incomplete and does nothing.

The debug basically shows that the conditional block ignored the code completely. Like I said before it seems to me that this doesn't work in the Block editor.

####################
wpv-conditional attributes
####################
Array
(
[if] => ( '' ne '' )
[debug] => true
)

####################
Debug information
####################
--------------------
Original expression: ( '' ne '' )
--------------------
After replacing 1 general variables and comparing strings: ( '' ne '' )
Comparing to

#1770819

My issue is resolved now. Thank you! It helps if I make sure the field names match the version of the product I am working on. That fixed everything once I updated your sample to match the fields I was currently working on instead of the ones in the generic example.

Thank you for the help.