Skip Navigation

[Resolved] Nested conditions in Elementor page builed

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

Problem:
The user is using nested conditional shortcodes inside of an Elementor text widget. The conditions are breaking.

Solution:
The Elementor Text Widget is an external 3rd party environment, and we can't guarantee if the nested shortcodes will work in that context.
Put the shortcodes in an unassigned content template, then include the content template with a shortcode:

[wpv-post-body view_template="Name or slug of the content template here"]

Relevant Documentation:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#vf-153372

This support ticket is created 3 years, 7 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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: Africa/Casablanca (GMT+00:00)

Tagged: 

This topic contains 7 replies, has 2 voices.

Last updated by deepS 3 years, 7 months ago.

Assisted by: Jamal.

Author
Posts
#1774051

Hi,
I want to put a nested condition in the Elementor page builder but I don't know why it's not executing whereas it works for normal conditional outputs.

[wpv-conditional if="( $(wpcf-course-start-date) ne '' ) AND ( $(wpcf-course-end-date) ne '' )"]
<div>
[wpv-conditional if="( $(wpcf-course-start-date) lte 'TODAY()' ) AND ( $(wpcf-course-end-date) gte 'TODAY()' )"]Ongoing Course2[/wpv-conditional]</div>
[/wpv-conditional]

Please help.

#1774097

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Hello and thank you for contacting the Toolset support.

Please correct me if I am wrong, I am not sure to understand the issue. I understand that you put conditional shortcodes inside an Elementor widget, and they work as expected. But when the conditional shortcodes are nested, they do not work, right?
To be sure of understanding, can you add a screenshot of where this code is added inside of Elementor?

In the meantime, I'll suggest putting these nested conditions inside of an unassigned content template, then include the content template with a shortcode:

[wpv-post-body view_template="Name or slug of the content template here"]

https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#vf-153372

#1775419
Screenshot_1.jpg

You got it right
I understand that you put conditional shortcodes inside an Elementor widget, and they work as expected. But when the conditional shortcodes are nested, they do not work, right?
Let me explain you things in detail:
I have two custom fields 'course start date' and 'course end date' and the conditional output code is

[wpv-conditional if="( $(wpcf-course-start-date) ne '' ) AND ( $(wpcf-course-end-date) ne '' )"]
[wpv-conditional if="('[types field='course-start-date' output='raw'][/types]' lt '[types field='course-end-date' output='raw'][/types]') AND ( $(wpcf-course-end-date) lt 'TODAY()' )"]Course_Ended_on: [types field='course-end-date' style='text' format='F j, Y'][/types][/wpv-conditional]
[wpv-conditional if="('[types field='course-start-date' output='raw'][/types]' lt '[types field='course-end-date' output='raw'][/types]') AND ( $(wpcf-course-end-date) gte 'TODAY()' )"]The Course is ongoing[/wpv-conditional]
[/wpv-conditional]

Hope you understand my conditions.
I put the following values:
Course start date: 01 September 2020
Course end date: 30 September 2020
It should show the following value:
'The Course is ongoing'
But in elementor page builder it is showing both the conditional values:
'Course_Ended_on: September 30, 2020'
'The Course is ongoing'
See the screenshot.

#1776903

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Thank you for your confirmation. I suppose that this is a bug that only appears with Elementor.

To be able to escalate it to our developers, we'll need to reproduce it on a clean install in our platform. For that reason, I created a new installation and I hope you will install Elementor on it and make a minimal example to demonstrate the issue. If reproduced, I'll escalate it to our 2nd Tier for another analysis before landing on the developers' list. You can log in to this test server with the following URL: hidden link

As a workaround, please test my previous suggestion about using a content template that holds these conditions, then include the content template in Elementor with a shortcode. If you have doubts implementing this solution, please reproduce the issue on the test server and I'll show how.

#1777043

See I have created a page. As it is Elementor free version it doesn't let me create a page template. But I have put the figures on a page hidden link where you can see the nested conditional code has been broken.

By the way, your trick to display the results with content template is working.

#1778731

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Thank you for your collaboration. I am escalating this to our 2nd Tier and I'll get back to you as soon as possible. Luckily, we can use a content template as a workaround.

#1778989

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

According to our 2nd Tier, these nested shortcodes are executed inside the Elementor Text Widget, which is an external 3rd party environment, and we can't guarantee if the nested shortcodes will work in that context.

As we do have a workaround for this case, we won't escalate this to our developers.

I hope this helps. Let me know your thoughts.

#1779909

My issue is resolved now. Thank you!

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