Skip Navigation

[Resolved] Conditional display field

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

Problem:
A non-Types custom field is used in a conditional shortcode, but test fails when the value of the field includes a apostrophe in the string.

Solution:
Inserting the conditional shortcode using the GUI will add the field condition in the required format which works, namely:

[wpv-conditional if="( $(notre_avis) ne '' )"]

Relevant Documentation:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/checking-fields-and-other-elements-for-emptynon-empty-values/

This support ticket is created 5 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.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 5 replies, has 2 voices.

Last updated by bouchairY 5 years, 7 months ago.

Assisted by: Nigel.

Author
Posts
#1262435

Hello
When I use :

<h4>NOTRE AVIS</h4>
[wpv-post-field name='notre_avis']

The field is displayed in the front but when I use :

[wpv-conditional if="( '[wpv-post-field name=notre_avis]' ne '' )"]
[vc_column_text]
<h4>NOTRE AVIS</h4>
[/vc_column_text]
[vc_empty_space height="15px"][vc_column_text][wpv-post-field name='notre_avis'][/vc_column_text]
[/wpv-conditional]

The field is not displayed !!

Thank you for your help

#1262473

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

In the line with your conditional shortcode you are missing single quotes around the name of the field, i.e.

[wpv-post-field name=notre_avis]

... should be...

[wpv-post-field name='notre_avis']
#1262857
content_view.jpg
content_view_new.jpg

Hello
Thank you for your reply
When I try to open the content view template, i have a problem
When I duplicate it, I can open the new one

Thank you for your help

#1263731

Hello

The problem is with the text, when i put the text below:

L'Atlantis The Palm est un magnifique hôtel --> NOT WORKING
LAtlantis The Palm est un magnifique hôtel --> WORKING

Code used :

[wpv-conditional if="( '[wpv-post-field name="notre_avis"]' ne ' ' )"]
[vc_column_text]
<h4>NOTRE AVIS</h4>
[/vc_column_text][vc_empty_space height="15px"][vc_column_text][wpv-post-field name="notre_avis"][/vc_column_text]
[/wpv-conditional]

Thank you

#1263747

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

There is still a problem with your condition

[wpv-conditional if="( '[wpv-post-field name="notre_avis"]' ne '' )"]

You need to use single quotes everywhere inside the if="" test.

But! Even so, in that format where your field includes an apostrophe in the value it doesn't work.

But! I just tested this, and if you insert the conditional shortcode using the GUI then it inserts it in this format:

[wpv-conditional if="( $(notre_avis) ne '' )"]

And in that case it does work correctly, if you want to try that.

#1263751

My issue is resolved now. Thank you!