Hi there,
We use Legacy for much of our sites, while on the rare occasion we use Blocks....the Conditional Block is very straight forward to use....and works great.
I saw a post on the forum that linked to this:
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
However I can't get my head round this.
This, part of one of our Legacy Grid Views...
<div class="col-sm-3"><span class='icon-style-1'><i class="fas fa-bed"><span class='number-style'>[types field='bedrooms' format='FIELD_VALUE'][/types]</span></span></div>
How and what would I need to wrap around this so it's hidden if the types field is left empty?
Thank you.
Hi Pete,
Thank you for getting in touch.
You can use the conditional below.
[wpv-conditional if="( '[types field='bedrooms' format='FIELD_VALUE'][/types]' ne '' )"]
<div class="col-sm-3"><span class='icon-style-1'><i class="fas fa-bed"><span class='number-style'>[types field='bedrooms' format='FIELD_VALUE'][/types]</span></span></div>
[/wpv-conditional]
This will only display the section in the conditional if the bedroom field is not empty.
Please let me know if this helps.
Thanks,
Shane
Hi Shane,
Long time no speak....hope all is well in your part of the world.
That worked GREAT! Thank you.
Final ask....using that code, or more the types field....is there a way to make the contents 'visible'?
Your previous hides the data perfectly however we need to replace it with something. The idea, to use an alternative code to display different contents using the same types filed.
Thanks again. Pete
Hi Pete,
I'm doing well 🙂 Hope you are as well.
Final ask....using that code, or more the types field....is there a way to make the contents 'visible'?
Your previous hides the data perfectly however we need to replace it with something. The idea, to use an alternative code to display different contents using the same types filed.
From this I gather that you want to display something if the field is empty correct? Rather than removing the information entirely. In this case you can simply check if the field is empty and then display your items.
Here is an example below.
[wpv-conditional if="( '[types field='bedrooms' format='FIELD_VALUE'][/types]' eq '' )"]
Some Content goes here.
[/wpv-conditional]
Please let me know if this helps.
Thanks,
Shane
Hi Shane,
Thanks very much for this. I see now with the code it the ' eq '' )"] for display and ne '' )"] to hide with certain types fields indicated.
Tried it and all works great. I didn't think Legacy would have codes and conditional would just be for Blocks.
Toolset saves the day again 🙂
Thanks very much for your help once again. Pete
Hi Pete,
No problem happy I was able to assist.
Yes our legacy mode does have conditionals and other various elements that can be used.
Most features in Blocks were built upon the legacy features or replaced with a simplified UI, for e.g the conditional block vs writing out the conditional shortcode manually.
If there are no further questions you can go ahead and mark this ticket as resolved.
Thanks,
Shane
My issue is resolved now. Thank you!