Skip Navigation

[Resolved] Conditional statement that evaluates across multiple Views

This thread is resolved. Here is a description of the problem and solution.

Problem:
Conditional statement that evaluates across multiple Views to check if view has posts or not

Solution:
You need to use [wpv-conditional] shortcode to check the view's output.

You can find the proposed solution, in this case, with the following reply:
https://toolset.com/forums/topic/conditional-statement-that-evaluates-across-multiple-views/#post-1223032

Relevant Documentation:
=> https://toolset.com/documentation/user-guides/conditional-html-output-in-views/
=> https://toolset.com/documentation/user-guides/view-layouts-101/#list-with-separators

This support ticket is created 5 years, 7 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 2 replies, has 2 voices.

Last updated by Ben 5 years, 7 months ago.

Assisted by: Minesh.

Author
Posts
#1222993

Ben

Is it possible to set up a conditional statement that evaluates across multiple views?

For example, something like this:

IF: View 1 results = >0 AND View 2 results = >0 then do: ACTION

#1223032

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Yes - this is possible.

For both of your view - you can choose the loop output format "List with separators" as well as checkmark the checkbox "Disable the wrapping DIV around the View" available with both of your view.
=> https://toolset.com/documentation/user-guides/view-layouts-101/#list-with-separators

Please check the following screenshot:
=> hidden link

Then, just empty out the views loop something like as given under - where we are using [wpv-found-count] shortcode to return the number of posts found:

[wpv-layout-start][wpv-items-found][wpv-found-count]<!-- wpv-loop-start --><wpv-loop></wpv-loop><!-- wpv-loop-end -->[/wpv-items-found][wpv-no-items-found]<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>[/wpv-no-items-found][wpv-layout-end]

More info:
=> https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-found-count

Later use the [wpv-conditional] shortcode:

[wpv-conditional if="( '[wpv-view id="999"]' gt '0' )" AND '[wpv-view id="888"]' gt '0' )"]
both views are NOT empty
[/wpv-conditional]

where:
- Replace the 999 and 888 with your view IDs

More info:
=> https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

#1224047

Ben

Thank you for this solution Minesh!

It works exactly how I want it to.