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