Navigation überspringen

[Gelöst] Make a conditional output in Views that only shows items based on checkbox state

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem:
A Toolset View conditional failed to display pages based on whether a specific option in a checkbox group was unchecked.

Solution:
Wrap the Types shortcode in single quotes inside the wpv-conditional expression so its returned value evaluates correctly. Alternatively, wrap the output with the Types shortcode using option='3' state='unchecked', noting that this only hides results and does not exclude them from View counts or pagination.

Relevant Documentation:
https://toolset.com/documentation/customizing-sites-using-php/functions/#checkboxes

This support ticket is created vor 3 days, 13 hours. 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.

Dieses Thema enthält 1 reply, hat 1 Stimme.

Zuletzt aktualisiert von nevilP vor 3 days, 9 hours.

Assistiert von: Christopher Amirian.

Author
Artikel
#2877668
Checkbox-group.png

I'm using WP Views to make a page list and need to only list pages that has a specific checkbox checked within a checkbox group.
Here is the code, that I would expect to work, but nothing is shown:

[wpv-conditional if="([types field='scope' option='3'][/types] ne 'block-robots')"]
	<li><em><u>versteckter Link</u></em></li>
[/wpv-conditional]

See attached image to see the checkbox group definition.
Thanks in advance 🙂

#2877679

Christopher Amirian
Unterstützer

Sprachen: Englisch (English )

Hi,

Welcome to Toolset support.

I suggest that you wrap the Types shortcode in single quotes inside the condition — without them it never evaluates:

[wpv-conditional if="( '[types field='scope' option='3'][/types]' ne 'block-robots' )"]
    <li><em><u>versteckter Link</u></em></li>
[/wpv-conditional]

For further reading:
https://toolset.com/documentation/customizing-sites-using-php/functions/#checkboxes

Also, maybe this would be a simpler way:

[types field='scope' option='3' state='unchecked']<li><em><u>versteckter Link</u></em></li>[/types]

Note this hides items in the output only; the View still queries them, so found counts and pagination include them.

Thanks.

#2877691

Thanks – now it works 🙂