Skip Navigation

[Resolved] Conditional Logic for Shortlist

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

This support ticket is created 2 years, 8 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
- 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 4 replies, has 2 voices.

Last updated by jacobB-3 2 years, 8 months ago.

Assisted by: Luo Yang.

Author
Posts
#2150961
Gap.png

I'm using Toolset legacy version on a new website for a school to display lists of their faculty, students and more. A previous support thread was really helpful to use [wpv-conditional if="( '[types field='people-publications' output='raw'][/types]' ne '')"][/wpv-conditional] shortcode to hide blank elements. I'm wondering if there's a similar way to do this with Checkboxes fields.

For example, I have grey badges appear below the photo corresponding to a person's association with school using the 'affiliation' field slug. These are selected via Checkboxes in Toolset and there are 8 or so categories. One Faculty Member has her badge show up appropriately, but then beneath her "Faculty" badge is an awkward space before we see her University badge.

hidden link

I think this is happening because I've added a 2px border between these affiliation badges - so there's nice separation between the badges when more than one is used. But in many cases these small spaces seem to add up creating a gap (see screenshot). If I could make these fields conditionally appear based on the selection of the Checkbox, that may resolve the issue...

#2151013

Hello,

It does not need [wpv-conditioal] shortcode, you can try with attribute "option" of Types shortcode directly, for example:

[types field="my-checkboxes" option="0"]here display some thing, the first option is checked[/types]
[types field="my-checkboxes" option="1"]here display some thing, the second option is checked[/types]
...

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.

#2154065

Thanks, Luo Yang!

That worked to display various faculty affiliations. But when a faculty member has more than one affiliation, is there a way to use conditional logic or other code to separate them? Currently, the Director of the school has "FACULTY STAFF" for her listing (options 0 and 2 are selected in the checkboxes), when it should be "FACULTY, STAFF".

hidden link

Is there a way to add a comma just when there's more than one affiliation (i.e., two or more checkboxes ticked)?

cheers,
Jacob

#2155041

You can try the wpv-conditonal shortcode, like this:

[wpv-conditional if="( '[types field='affiliation'][/types]' ne '')"]
[types field='affiliation'  separator=' ,'][/types]
[/wpv-conditional]

More help:
https://toolset.com/documentation/legacy-features/views-plugin/checking-fields-and-other-elements-for-emptynon-empty-values/#checking-types-checkboxes-field-for-non-empty-value

#2155831

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.