Skip Navigation

[Resolved] Conditional display of Views

This support ticket is created 4 years, 10 months ago. 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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by Vane 4 years, 10 months ago.

Assisted by: Shane.

Author
Posts
#1477017

Hi,

I have 2 CPTs in one-to-many Relationship, where CPT-A is the "one", CPT-B is the "many".
(Imagine Yelp: every each Restaurant may have mutiple ratings / reviews)
I want to display the filtered list of CPT-Bs on specific CPT-A pages, with further filtering
(analogy: on every each Restaurant page there's only the ratings/reviews related to that specific restaurant and you can refine them by eg. filtering only 3 star rating reviews and above)

I want to display this block containing user filters and this list ( meaning a Toolset View) only if there is any related CPT-B.
(analogy: I only want to show the content block containing review filters and reviews if there is at least 1 related review of that specific Restaurant)

( the really correct method would be let's say if there are:
at least 6 related reviews, then show View (with both Search and Result section),
else if 1-3 related reviews they have, then show View (but only Result section),
else, it is 0, doesn't show View at all. )

This time I can not set up such condition, or I couldn't figure out how...

Thank you

#1477203

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Vane,

Thank you for getting in touch.

Unfortunately no this won't be possible to achieve at all with our conditionals. You will need to come up with a custom conditional code to wrap your view inside this.

Your custom conditional should be written to check for the parameters that you want. Unfortunately i'm not able to assist with this as such custom coding would be out of the scope of our support forum.

Thanks,
Shane

#1477973

Solution:

we must add the view's "Search & Pagination" section in a conditional shortcode, like:

[wpv-conditional if="( '[wpv-found-count]' gt '0' )"]
***
[/wpv-conditional]

EDIT:
[wpv-items-found]
must also work...

This way we can hide filter if there's no content to be filtered.
We can further refine display mode tweaking this condition.

Feature is also available from Conditional Block, selecting "Views shortcode".