Skip Navigation

[Resolved] Dynamic Conditions on a field with checkboxes?

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

Our next available supporter will start replying to tickets in about 0.79 hours from now. 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: Asia/Hong_Kong (GMT+08:00)

This topic contains 12 replies, has 2 voices.

Last updated by jorg-andreasK 5 years ago.

Assisted by: Luo Yang.

Author
Posts
#1391477

Hi there,

I want to use a Plugin for Dynamic Conditions,... which gives me the results I need so far, even in combination with toolset.

In a CPT I have a field for Checkboxes enabeling the editor to check more than one Checkbox.

In general I easely can show an image in condition to any field of my CPT field except one... how can I use a Checkbox field to show me an image depending on the value of Checkbox?

strangly this field is not available in Elementor or the dynamic conditions plugin,...

Or alternativly I am thinking of building a view, just showing images on separate conditions related to the checked boxes of the CPT. but how to trigger that in a view?

Jörg

#1391525
Bildschirmfoto 2019-11-25 um 17.25.02.png

The row with the 7 Icons U7 to U12 ( in my screenshot), I want to show or hide depending on the Checked Boxes of my CPT Field

Iam talking about a single Post of my CPT.

#1392085

Hello,

I assume we are talking about a custom checkboxes field created with Types plugin.

If it is, you can display different image/text by checkboxes field values, for example:

[types field="my-checkboxes" option="0" state="checked"]image of option 1[/types]
[types field="my-checkboxes" option="1" state="checked"]image of option 2[/types]
[types field="my-checkboxes" option="2" state="checked"]image of option 3[/types]
...

More help:
https://toolset.com/documentation/customizing-sites-using-php/functions/#checkboxes

#1392355

Hi there again

Thx for your reply and recommendations.

I guess I understand what to do now. But I am a bit confused where to put the customized code. In a view, in the Loop editor?

Or ist just for a html-widget in Elementor?

Jörg

#1392897

Those are just WordPress shortcodes, you can put it into anywhere supports shortcodes, for example: post content, text/html widgets.

#1392967

Hi there again

and thx for your reply again.

Are you sure about the braces? thought WP shortcode have a [] braces.

Anyway,... can`t bring this to work:

{{types field="altersklassen" option="E-Junioren U10" state="checked"}}<img src="hidden link alt="E-Junioren U10">[/types}}

"altersklassen is the slug of the field and "E-Junioren U10" is the Value.

Any Idea what my mistake is?

best regards
Jörg

#1392971

Dear Jörg,

Yes, you are right, there is a mistake in the codes I mentioned above, there should not be "[".

The attribute "option" support numeric value: 0, 1, 2...
See our document:
https://toolset.com/documentation/customizing-sites-using-php/functions/#checkboxes
option:
"zero-based index number"
e.g. option=”0″ Will output the value for the option number specified. For checkboxes, will display the checked valued of the nth checkbox in the group.

For example, you are going to check the first option of the custom checkboxes field, so the attribute "option" value should be 0, you can try to modify the code you mentioned above as below:

{!{types field="altersklassen" option="0" state="checked"}!}<img src="<em><u>hidden link</u></em> alt=" e-junioren="" u10"="">{!{/types}!}

And test again.

#1392991

Here is update from our 2nd tier supporters, we recommend to use [] shortcode wrapper unless GUI generates {!{, so the example should be these:

[types field="altersklassen" option="0" state="checked"]<img src="<em><u>hidden link</u></em> alt=" e-junioren="" u10"="">[/types]

Here is the details from our 2nd tier supporers:
You should use [ ].
Only if the GUI generates {!{ then you have to use that syntax.
This is a syntax made for “compatibility”, to avoid certain themes executing Toolset shortcodes before they are rendered.
So we implemented the {!{ syntax to avoid Themes executing those shortcodes before we want, giving Toolset the control when to execute its own shorcodes

#1393071

Hi there again,...

Thx for your replay ,... and we are very close now.

This one here works:

[types field="altersklassen" option="4" state="checked"]<img src="hidden link" alt="" style="width:45px;height:45px;">[/types]

But how to list another shortcode?

If I add another in the next line the 2nd image does not work i.e.

[types field="altersklassen" option="4" state="checked"]<img src="hidden link" alt="" style="width:45px;height:45px;">[/types]

[types field="altersklassen" option="5" state="checked"]<img src="hidden link" alt="" style="width:45px;height:45px;">[/types]

Do I have to have a widget or each , or how to list it? With a Comma?

Jörg

#1393077

Hi there,

It works now!!!

There was another issue on the checked boxes.

But last question: How to show a different image for all checkboxes unchecked? What is the right spelling prior to the image path?

Jörg

#1393081

You can use [wpv-conditional] shortcode to check if all checkboxes unchecked, for example:

[wpv-conditional if="( $(wpcf-altersklassen) eq '' )"]
Another image here ...
[/wpv-conditional]

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

#1393133

Hi there last time

Thx for your 1st Class support, everything works as needed.

Thank you very much and

best regards from Germany

Jörg

#1393135

My issue is resolved now. Thank you!