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?
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.
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.
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.