Skip Navigation

[Resolved] I don't want to display view if it doesn't return any items

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 3 replies, has 2 voices.

Last updated by Minesh 11 months, 1 week ago.

Assisted by: Minesh.

Author
Posts
#2684363
Upcoming events.png

I have a view that displays upcoming events on my home page. I have a Title which reads "Upcoming Events" which is before the view Loop. I don't want to display that empty view, but rather do something else like displaying past events in case there is no upcoming event. How can i achieve this?

What is the link to your site?
hidden link

Thanks

#2684410

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

You should try to follow the following steps:
- Add a view block, for instance "view-for-no-items-found" to your page and display the items you want to this view's loop and save the page
- delete the view block for "view-for-no-items-found"
- select your existing view block that shows "No Items found" message and select the "View Loop" and on right sidebar you will see the "Loop Template" tab. Please check the following screenshot: hidden link
- To this Loop template tab - you should add your view: [wpv-view name="view-for-no-items-found"]

I hope the above information will help you to fix your issue.

#2684508
Upcoming events 2.png

Hi Minesh,
I don't understand how your proposed solution prevents the original title "Upcoming Events" from being displayedexcept I am missing something.
As you can see, the title is above the view and will therefore always be displayed which is exactly what I don't want.
Maybe I did't understand your proposed solution above. If there is no upcoming event, I don't want the title to be displayed at all.
In PHP it will be something like if(COUNT($upcoming_events_array) > 0) then show the block with upcoming else show block with past events.

#2684544

Minesh
Supporter

Languages: English (English )

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

Ok - if you want to hide the heading when view do not have any result.

Try to add a conditional block and configure it to check with view's shotcodes and further select "number of items found in view" and compare it as shown with the following image:
=> hidden link

Then move the conditional block between view's output and view's loop section as shown with the following image:
=> hidden link

And add whatever block to display the heading for your view within the conditional block and save.

I hope this will help.