Skip Navigation

[Gelöst] Creating conditional logic to display dates from Modern Tribe Events Calendar

This support ticket is created vor 1 Jahr, 8 Monaten. 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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

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)

Dieses Thema enthält 4 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von joshM-4 vor 1 Jahr, 8 Monaten.

Assistiert von: Luo Yang.

Author
Artikel
#2579331

I've registered the _EventStartDate and _EventEndDate fields from Modern Tribe Events Calendar in Toolset and am able to successfully display them. What I'm wanting to do is conditionally control what is displayed depending on whether the event takes place in a single day, or across multiple days. For example...

If one day: "May 1, 2023"
If multiple days: "May 1 – May 5, 2023"

This is the statement I currently have but it's not displaying the end date:

[date-format date="[wpv-post-field name='_EventStartDate']" format="M j"][wpv-conditional if="( '[date-format date='[wpv-post-field name='_EventStartDate']' format='M j']' ne '[date-format date='[wpv-post-field name='_EventEndDate']' format='M j']' )"]-[date-format date="[wpv-post-field name='_EventEndDate']" format="M j"][/wpv-conditional][date-format date="[wpv-post-field name='_EventEndDate']" format=", Y"]

Any help you can offer is greatly appreciated.

----

What is the link to your site? versteckter Link

#2579683

Hello,

There isn't such kind of built-in feature within Toolset plugins, I have searched it in Google, and found this thread:
versteckter Link

It seems you can use their function tribe_event_is_multiday() to check if specific event post is a multiple days event.

You might consider to setup custom codes to create a PHP function check the event post, and follow our document to add the function name into Toolset settings:
https://toolset.com/documentation/programmer-reference/views/using-custom-functions-in-conditions/

#2579877

Thank you, Luo, this is very helpful.

I found the documentation on that function, which I added to Toolset's "Functions inside conditional evaluations" but for some reason it's not working. The documentation (versteckter Link) says the return is boolean but it doesn't seem to be working in my conditional statement.

I've got to be missing something, right? Here's what I have presently:

[date-format date="[wpv-post-field name='_EventStartDate']" format="M j"]
[wpv-conditional if="( tribe_event_is_multiday() eq '1' )"]-[date-format date="[wpv-post-field name='_EventEndDate']" format="M j"][/wpv-conditional]
[date-format date="[wpv-post-field name='_EventEndDate']" format=", Y"]

Thoughts on what I'm missing? Any additional help is greatly appreciated!

#2581119

Here is a sandbox website:
Login URL:
versteckter Link

1) Dashboard-> Toolset-> Settings-> Front-end Content:
versteckter Link
In section "Functions inside conditional evaluations", add the function name: tribe_event_is_multiday

2) Create a event post, and display the shortcode like this:

[wpv-conditional if="( tribe_event_is_multiday([wpv-post-id]) eq '1' )"]
Multiday Event:
[date-format date="[wpv-post-field name='_EventStartDate']" format="M j"] - [date-format date="[wpv-post-field name='_EventEndDate']" format=", Y"]
[/wpv-conditional]

[wpv-conditional if="( tribe_event_is_multiday([wpv-post-id]) eq '1' )" evaluate="false"]
Single day Event:
[date-format date="[wpv-post-field name='_EventStartDate']" format="M j"]
[/wpv-conditional]

Test it in frontend:
versteckter Link

It works fine. For your reference.

#2581447

My issue is resolved now. Thank you!