Home › Toolset Professional Support › [Resolved] Hide a View using old-fashioned Views (not conditional blocks)
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/Karachi (GMT+05:00)
Tagged: Views, Views plugin
This topic contains 4 replies, has 2 voices.
Last updated by chantalM 3 years, 9 months ago.
Assisted by: Waqar.
Tell us what you are trying to do?
I have a View with the following field within it:
[types field="booking-until" format="D d M Y"][/types]
When the 'booking until' date arrives I want the whole View to disappear.
eg booking until the 6th Sept, after this date the view disappears because it is no longer available
Is there any documentation that you are following?
I don't use Gutenberg/conditional blocks, I still use the old-fashioned Views so the new training materials do not pertain to this
Is there a similar example that we can see?
What code do I need to wrap it in please? I have no idea how to structure the wpv-conditional (or WPV-IF?) as there is no longer a reference that I can find online.
Hi,
Thank you for contacting us and I'd be happy to assist.
In your view's "Loop Editor", you can wrap the loop item's output, inside a conditional check, like this:
.... <wpv-loop> [wpv-conditional if="( $(wpcf-booking-until) gte 'TODAY()' )"] ..... [/wpv-conditional] </wpv-loop> ....
As a result, the view will only show any result if the "booking-until" date field is greater than or equal to today's date, and if there is no such post, then no results will be shown.
You can read about the legacy conditional display feature and date functions from these guides:
https://toolset.com/documentation/legacy-features/views-plugin/conditional-html-output-in-views/
https://toolset.com/documentation/user-guides/views/date-filters/
regards,
Waqar
Waqar, thank you so much. That's great.
Using the code you have given me, could you also let me know how I would make the View appear?
Thanks for the update.
To show some content in an inverse condition (i.e. when the booking date has lapsed), you can replace 'gte' (greater than or equal to) with 'lte' (lower than or equal to) in the same condition.
My issue is resolved now. Thank you!