Skip Navigation

[Résolu] Help with Radio Button Conditional

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

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)

This topic contains 12 réponses, has 4 voix.

Last updated by Daniella Il y a 10 années et 1 mois.

Assigned support staff: Luo Yang.

Auteur
Publications
#77598
Screen shot 2013-04-11 at 10.19.14 AM.png

Hi,
I have the following code in my Content Template:

<div id="ccp">
<dl>
[wpv-if f1="wpcf-camps" evaluate="$f1 != 3"]<dt><strong>camps:</strong></dt> <dd>[types field="camps" class="" style=""][/types] [wpv-if field="wpcf-camp-url" evaluate="empty($field)"][/wpv-if][wpv-if field="wpcf-camp-url" evaluate="!empty($field)"]<a href="[types field="camp-url" raw="true"][/types]" target="_blank">(Visit Website)</a> | [/wpv-if]  [wpv-if field="wpcf-camp-pdf" evaluate="empty($field)"][/wpv-if][wpv-if field="wpcf-camp-pdf" evaluate="!empty($field)"]<a href="[types field="camp-pdf" raw="true"][/types]" target="_blank">(Download pdf)</a>[/wpv-if]</dd>
[/wpv-if]

[wpv-if f1="wpcf-classes" evaluate="$f1 != 3"]<dt><strong>classes:</strong></dt> <dd>[types field="classes" class="" style=""][/types] [wpv-if field="wpcf-school-url" evaluate="empty($field)"][/wpv-if][wpv-if field="wpcf-school-url" evaluate="!empty($field)"]<a href="[types field="school-url" raw="true"][/types]" target="_blank">(Visit Website)</a> | [/wpv-if][wpv-if field="wpcf-school-pdf" evaluate="empty($field)"][/wpv-if][wpv-if field="wpcf-school-pdf" evaluate="!empty($field)"]<a href="[types field="school-pdf" raw="true"][/types]" target="_blank">(Download pdf)</a>[/wpv-if]</dd>[/wpv-if]

[wpv-if f1="wpcf-parties" evaluate="$f1 != 3"]<dt><strong>parties:</strong></dt> <dd>[types field="parties" class="" style=""][/types] [wpv-if field="wpcf-parties-url" evaluate="empty($field)"][/wpv-if][wpv-if field="wpcf-parties-url" evaluate="!empty($field)"]<a href="[types field="parties-url" raw="true"][/types]" target="_blank">(Visit Website)</a> | [/wpv-if][wpv-if field="wpcf-parties-pdf" evaluate="empty($field)"][/wpv-if][wpv-if field="wpcf-parties-pdf" evaluate="!empty($field)"]<a href="[types field="parties-pdf" raw="true"][/types]" target="_blank">(Download pdf)</a><br />[/wpv-if]</dd>[/wpv-if]
</dl>
</div>

I have attached a screenshot of the Custom Field and how it is set up.

As you can see on <a href="hidden link">this link</a>, the content is still showing up even though it is set not to. Basically, if the value is 3 or N/A, I don't want this to show.

Any help would be much appreciated.
Thank you.

#77725

Dear Daniella,

Try to replace your code using simple quotes like this below:

<div id="ccp">
<dl>
[wpv-if f1="wpcf-camps" evaluate="$f1 != '3'"]<dt><strong>camps:</strong></dt> <dd>[types field="camps" class="" style=""][/types] [wpv-if field="wpcf-camp-url" evaluate="empty($field)"][/wpv-if][wpv-if field="wpcf-camp-url" evaluate="!empty($field)"]<a href="[types field="camp-url" raw="true"][/types]" target="_blank">(Visit Website)</a> | [/wpv-if]  [wpv-if field="wpcf-camp-pdf" evaluate="empty($field)"][/wpv-if][wpv-if field="wpcf-camp-pdf" evaluate="!empty($field)"]<a href="[types field="camp-pdf" raw="true"][/types]" target="_blank">(Download pdf)</a>[/wpv-if]</dd>
[/wpv-if]
 
[wpv-if f1="wpcf-classes" evaluate="$f1 != '3'"]<dt><strong>classes:</strong></dt> <dd>[types field="classes" class="" style=""][/types] [wpv-if field="wpcf-school-url" evaluate="empty($field)"][/wpv-if][wpv-if field="wpcf-school-url" evaluate="!empty($field)"]<a href="[types field="school-url" raw="true"][/types]" target="_blank">(Visit Website)</a> | [/wpv-if][wpv-if field="wpcf-school-pdf" evaluate="empty($field)"][/wpv-if][wpv-if field="wpcf-school-pdf" evaluate="!empty($field)"]<a href="[types field="school-pdf" raw="true"][/types]" target="_blank">(Download pdf)</a>[/wpv-if]</dd>[/wpv-if]
 
[wpv-if f1="wpcf-parties" evaluate="$f1 != '3'"]<dt><strong>parties:</strong></dt> <dd>[types field="parties" class="" style=""][/types] [wpv-if field="wpcf-parties-url" evaluate="empty($field)"][/wpv-if][wpv-if field="wpcf-parties-url" evaluate="!empty($field)"]<a href="[types field="parties-url" raw="true"][/types]" target="_blank">(Visit Website)</a> | [/wpv-if][wpv-if field="wpcf-parties-pdf" evaluate="empty($field)"][/wpv-if][wpv-if field="wpcf-parties-pdf" evaluate="!empty($field)"]<a href="[types field="parties-pdf" raw="true"][/types]" target="_blank">(Download pdf)</a><br />[/wpv-if]</dd>[/wpv-if]
</dl>
</div>

Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.

#77729

I tried that and it didn't work. I tried different operators '<' and it didn't work. I removed the nested if statement, didn't work.
Here is the revised code that doesn't work:

<div id="ccp">
<dl>
[wpv-if f1="wpcf-camps" evaluate="$f1 != '3'"]<dt><strong>camps:</strong></dt> <dd>[types field="camps" class="" style=""][/types][/wpv-if] [wpv-if field="wpcf-camp-url" evaluate="empty($field)"][/wpv-if][wpv-if field="wpcf-camp-url" evaluate="!empty($field)"]<a href="[types field="camp-url" raw="true"][/types]" target="_blank">(Visit Website)</a> | [/wpv-if]  [wpv-if field="wpcf-camp-pdf" evaluate="empty($field)"][/wpv-if][wpv-if field="wpcf-camp-pdf" evaluate="!empty($field)"]<a href="[types field="camp-pdf" raw="true"][/types]" target="_blank">(Download pdf)</a>[/wpv-if]</dd>


[wpv-if f2="wpcf-classes" evaluate="$f2 != '3'"]<dt><strong>classes:</strong></dt> <dd>[types field="classes" class="" style=""][/types][/wpv-if] [wpv-if field="wpcf-school-url" evaluate="empty($field)"][/wpv-if][wpv-if field="wpcf-school-url" evaluate="!empty($field)"]<a href="[types field="school-url" raw="true"][/types]" target="_blank">(Visit Website)</a> | [/wpv-if][wpv-if field="wpcf-school-pdf" evaluate="empty($field)"][/wpv-if][wpv-if field="wpcf-school-pdf" evaluate="!empty($field)"]<a href="[types field="school-pdf" raw="true"][/types]" target="_blank">(Download pdf)</a>[/wpv-if]</dd>

[wpv-if f1="wpcf-parties" evaluate="$f1 != '3'"]<dt><strong>parties:</strong></dt> <dd>[types field="parties" class="" style=""][/types][/wpv-if] [wpv-if field="wpcf-parties-url" evaluate="empty($field)"][/wpv-if][wpv-if field="wpcf-parties-url" evaluate="!empty($field)"]<a href="[types field="parties-url" raw="true"][/types]" target="_blank">(Visit Website)</a> | [/wpv-if][wpv-if field="wpcf-parties-pdf" evaluate="empty($field)"][/wpv-if][wpv-if field="wpcf-parties-pdf" evaluate="!empty($field)"]<a href="[types field="parties-pdf" raw="true"][/types]" target="_blank">(Download pdf)</a><br />[/wpv-if]</dd>
</dl>
</div>

Any ideas?

#77737

Let me add (and I just realized this) that if I go into the Dashboard and click "Update" on the Edit Listing page the conditional statement works. However, there are more than 800 Listings.
Please tell me there is a fix.

#77961

Bigul
Supporter

Dear Daniella,

Please export your Types and Views settings and send it to my mail -> bigul@wpml.org for debugging it.

--
With Regards

Bigul

#78125

I tried to send it to that email but am getting a Delivery Failure notice. Is that the correct email?
Thank you.

#78965

Bigul
Supporter

Hi Daniella,

Sorry. Please send it to my mail bigul.m@wpml.org.

--
With Regards

Bigul

#79444

Luo Yang
Supporter

Languages: Anglais (English ) Chinois simplifié (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Hi Daniella,

Nested wpf-if shortcodes wont work

Views uses the WordPress shortcode processing for the [wpv-if] shortcode. WordPress has limitations on:
http://codex.wordpress.org/Shortcode_API#Nested_Shortcodes

More help: https://toolset.com/documentation/user-guides/conditional-html-output-in-views/#Important%20notes

I suggest you try this:
1) create 3 other different view templates, such as "camps Content Template", "classes Content Template", "parties Content Template",
edit "camps Content Template", put shortcodes in it, like this:

<dt><strong>camps:</strong></dt> <dd>[types field="camps" class="" style=""][/types] [wpv-if field="wpcf-camp-url" evaluate="empty($field)"][/wpv-if][wpv-if field="wpcf-camp-url" evaluate="!empty($field)"]<a href="[types field="camp-url" raw="true"][/types]" target="_blank">(Visit Website)</a> | [/wpv-if]  [wpv-if field="wpcf-camp-pdf" evaluate="empty($field)"][/wpv-if][wpv-if field="wpcf-camp-pdf" evaluate="!empty($field)"]<a href="[types field="camp-pdf" raw="true"][/types]" target="_blank">(Download pdf)</a>[/wpv-if]</dd>

edit "classes Content Template", put shortcodes in it ...
edit "parties Content Template", put shortcodes in it ...

2) edit your view template as this, modify it like this:

<div id="ccp">
<dl>
[wpv-if f1="wpcf-camps" evaluate="$f1 != 3"]
[wpv-post-body view_template="camp view template"]
[/wpv-if]
...
</dl>
</div>

Please let me know if you need assit to do it.

Regards
Luo

#79603

Hi Luo,
Did you read my additional responses above? I did omit the nested if statement. I got the statement to work as it is in the view template but only if I go to that Listing and click Update. There are over 800 listings.
I believe this is a bug.

#79825

Luo Yang
Supporter

Languages: Anglais (English ) Chinois simplifié (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

I am not sure what is the prolem "There are over 800 listings" you mentioned above, could you send the login detail of your website to my email: luo.y@onthegosystems.com
Also point out the problem page URL and the view template URL.
I need duplicate same problem in my localhost. if it is a bug, I will forward it to our developers.
thanks

#80006

I just sent it to you.

#80296

Luo Yang
Supporter

Languages: Anglais (English ) Chinois simplifié (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

You are right when the field "camps", "classes" and "parties" are empty, wpv-if should return false, and I have modified your view template as these:

[wpv-if f1="wpcf-camps" evaluate="(!empty($f1)) AND ($f1 != 2)" debug="true"]
...
[/wpv-if]

Please check it again if it works or not.

And I have forward it to our developers about this problem.

#80516

Thank you so much!. It worked.