Home › Toolset Professional Support › [Waiting for user feedback] Hide or show block based on value checkbox
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.
This topic contains 3 replies, has 1 voice.
Last updated by Christopher Amirian 23 hours, 1 minute ago.
Assisted by: Christopher Amirian.
I'm using Greenshift to build a website. It has a visibility option, which is similar to Toolset's conditional block. So you can show or hide content based on conditions.
In Toolset, I have created a custom field with checkboxes. So the custom field slug is "dj-feesten" and it has values like "dj-bruiloft", "dj-16-verjaardag", "dj-40-verjaardag" etcetera.
I have also created a grid with blocks for each "soort feest". Now, if "dj-bruiloft" is checked, the corresponding block it should be shown, but if it's not checked, it should be hidden.
In Greenshift's visibility options, I can use any custom meta with the following options:
Custom field key
Custom field value (Divide by | your range values, example 0|100)
Operator
I have the following operators:
<
<=
=
=>
>
!=
EXCIST
NOT EXCIST
BETWEEN
However, I can't figure out which meta to use. I've tried a number of options like:
Custom field key "wpcf-dj-feesten"
Value "dj-bruiloft"
Operator "="
Custom field key "wpcf-dj-feesten"
Value "wpcf-dj-bruiloft"
Operator "="
Custom field key "dj-bruiloft"
Value "0"
Operator "="
Custom field key "wpcf-dj-bruiloft"
Value "0"
Operator "="
Etcetera, but none of them seem to work
Hi,
Welcome to Toolset support. This is something that you need to consult with the developers of Greenshift as we do not have information on how their code works.
What I can suggest is that you use the types shortcode to show the custom field you want to put in the conditional to see what is the actual value that is generated by Toolset for that item.
Make sure you know what it is and it is not blank and then try to use it in the conditional.
The reason I ask you to do that is that sometimes the context that the Toolset custom field is used should be inside a view or somewhere that the data of the custom post type that the custom field is in should be available first, and if you use it out of that context Toolset will not show anything.
https://toolset.com/documentation/customizing-sites-using-php/functions/
Thanks.
Greenshift support writes:
If toolset is saving field value in array (highly likely), you can't check by visibility because you can't compare array value.
You can use other type of fields (not multiple choice fields) or build custom visibility by Hook. Query builder has special hooks that you can use to add custom visibility and documentation has example
hidden link
So is Toolset saving checkboxes value in array? If not, how then?
Hi,
Thank you and sorry for the late reply due to the weekend time.
I checked and the Checkboxes fields are stored in an array.
Just so you know Toolset has conditional blocks that you can use instead of the plugin in question, the conditional blocks in Toolset work ok with our checkboxes:
https://toolset.com/course-lesson/using-toolset-conditional-block/
Thanks.