Skip Navigation

[Résolu] Creating conditional logic to display dates from Modern Tribe Events Calendar

This support ticket is created Il y a 1 année et 8 mois. 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.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

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)

Ce sujet contient 4 réponses, a 2 voix.

Dernière mise à jour par joshM-4 Il y a 1 année et 8 mois.

Assisté par: Luo Yang.

Auteur
Publications
#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? lien caché

#2579683

Hello,

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

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 (lien caché) 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:
lien caché

1) Dashboard-> Toolset-> Settings-> Front-end Content:
lien caché
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:
lien caché

It works fine. For your reference.

#2581447

My issue is resolved now. Thank you!