Skip Navigation

[Gelöst] hide search view if there is not search results and display another element

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem:

I'm trying to design a page with a view that will display the users with all their posts. however if the use never publish a post before i want to hide the view and display a button to create their first post.

Solution:

You can try these:

https://toolset.com/forums/topic/hide-search-view-if-there-is-not-search-results-and-display-another-element/#post-2076851

Relevant Documentation:

This support ticket is created vor 2 Jahre, 11 Monate. 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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

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/Hong_Kong (GMT+08:00)

Dieses Thema enthält 4 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von davidZ-4 vor 2 Jahre, 11 Monate.

Assistiert von: Luo Yang.

Author
Artikel
#2076469

Tell us what you are trying to do? hide search view if there is not search results and display another element.
the site allow users to publish their own custom posts.
I'm trying to design a page with a view that will display the users with all their posts. however if the use never publish a post before i want to hide the view and display a button to create their first post.

Is there any documentation that you are following?
https://toolset.com/documentation/programmer-reference/views-filters/
https://toolset.com/documentation/programmer-reference/views-api/

Is there a similar example that we can see?
I have done before using the toolset legacy view plugin. I used toolset conditional element to display a button if the the search results are empty.
With the new view block I'm not sure how to do this.

What is the link to your site?
versteckter Link

#2076851
no-item.JPG

Hello,

I assume you are using WordPress blocks editor, and we are talking about View block, if it is, please try these:
1) Find and select "View Loop" block, in section "Loop Template", input box "No Items Found Text", there you can setup the Button HTML codes you wanted, see my screenshot no-item.JPG

2) If you want to hide entire search result element, you can setup CSS codes into input box "No Items Found Text", for example:

<style>
.js-wpv-view-layout{
display:none;
}
</style>
#2079877

Hi Luo,
Thanks for this, its partially answer my question.
allow me to elaborate on the scenario:
user register to the site, and never submit a custom post.
to submit a post user can go to "my custom posts" page that have a view that search and display all custom posts user publish.
however as the user never submit custom post the view should be hidden and a button to create a post display.
I hope we can hide the search criteria as well as no post are available.
I remember building this with the old view and I wonder if this can be replicated with the new view block.
Please advise,
Thanks,
David

#2079943

Unfortunately, there isn't such kind of built-in feature within Toolset Blocks plugin, you might consider to hide the custom search form with CSS codes too, see my answer above:
https://toolset.com/forums/topic/hide-search-view-if-there-is-not-search-results-and-display-another-element/#post-2076851

#2080625

My issue is resolved now. Thank you!

Dieses Ticket ist jetzt geschlossen. Wenn Sie ein Toolset Kunde sind und Hilfe benötigen, eröffnen Sie bitte ein neues Support-Ticket.