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.
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
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.
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.
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.
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.
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.
My issue is resolved now. Thank you!