Skip Navigation

[Résolu] If a user choose a category or anything in the search form, it not shows correct

This support ticket is created Il y a 5 années. 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.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

Ce sujet contient 21 réponses, a 2 voix.

Dernière mise à jour par fred-r.M Il y a 5 années.

Assisté par: Nigel.

Auteur
Publications
#1349659

If a user choose anything in the search form: lien caché

it not showing the whole results correct.

Also - in firefox it shows nothing. For "not showing" the results before a customer choose something I have a script:

<code:<script>
function Search() {
document.getElementById("myresults").style.display = "block";
}
</script>[/php]

Link to a page where the issue can be seen: lien caché

#1349791

Nigel
Supporter

Les langues: Anglais (English ) Espagnol (Español )

Fuseau horaire: Europe/London (GMT+01:00)

Firstly, there are better ways to not show any initial results before a selection has been made than hiding the results with CSS (which means that the results still get sent to the browser).

You can wrap the wpv-loop section of your View in a conditional shortcode which tests for the presence of a URL parameter that gets added when a search filter is applied, and only show the loop when that parameter exists (otherwise it is the first visit to the page and no search has been specified yet).

Here is how that would look:

[wpv-layout-start]
    [wpv-items-found]
    <!-- wpv-loop-start -->
    [wpv-conditional if="( '[wpv-search-term param='wpv_view_count']' ne '' )"]
        <wpv-loop>
          <!-- you loop content goes here -->
        </wpv-loop>
    [/wpv-conditional]
    <!-- 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]

Now, if I expose the results on your page (by changing the #myresults to display:block) then the results are all in a narrow column on the left. I'm having problems understanding the markup because your View appears to be inserted multiple times (presumably related to the map displayed at the top), and you are using a page builder.

Can I look at your site to see?

I will mark your next reply as private so that I can get log-in credentials from you—you may want to create a temporary admin user for me to use that you can later delete. And be sure to have a current backup of your site.

#1350037

Nigel
Supporter

Les langues: Anglais (English ) Espagnol (Español )

Fuseau horaire: Europe/London (GMT+01:00)

I can't work out where you added the custom JS and CSS to hide the results to be able to look at them without that modification.

Could you please disable that and then let me know when you've done that?

#1350093

Dear Nigel

I added it in Impreza -> Theme Options -> Custom Code

Finally I taked the js code out now

And the css code was in the child theme style.css, I taked it out there too.

#1350127

Nigel
Supporter

Les langues: Anglais (English ) Espagnol (Español )

Fuseau horaire: Europe/London (GMT+01:00)

So, why can't I see any results on the Phuket page, then?

#1350671

Hi Nigel

It is working - respectively - the result is there, without choosing anything: lien caché

Do You might have an issue with the cache?

#1351297

Dear Nigel

Are You still on this ticket?

Regards,

Simon

#1351405

Nigel
Supporter

Les langues: Anglais (English ) Espagnol (Español )

Fuseau horaire: Europe/London (GMT+01:00)

Yes, sorry, I don't work at the weekend. I've just started and will get back to this this morning.

#1351447

Nigel
Supporter

Les langues: Anglais (English ) Espagnol (Español )

Fuseau horaire: Europe/London (GMT+01:00)

Screenshot 2019-09-30 at 08.28.35.png

OK, the page appears to be working now, and it looks to be working as expected, so I'm not sure any longer what the problem is I'm supposed to be addressing?

#1351503

Hi Nigel

The main thing is, I not want, that the results are showing from the beginning. It used to start show, when a customer change anything in the search form (dropdowns, or do a fulltext search).

#1351505

Nigel
Supporter

Les langues: Anglais (English ) Espagnol (Español )

Fuseau horaire: Europe/London (GMT+01:00)

The let me refer you back to my first answer, which is I think the easiest way to implement this.

https://toolset.com/forums/topic/if-a-user-choose-a-category-or-anything-in-the-search-form-it-not-shows-correct/#post-1349791

You just need to add the opening and closing wpv-conditional shortcodes around the wpv-loop tags, as shown in the sample code.

#1351611

Dear Nigel

I did, but it still showing all listings in the beginning. Or do I need to set something special or anything else in the view?

Regards,

#1351617

Nigel
Supporter

Les langues: Anglais (English ) Espagnol (Español )

Fuseau horaire: Europe/London (GMT+01:00)

It seems you added back the CSS to set display:none on the results, so I can't test if it is working.

#1351653

Hi Nigel

I did not set anything back or so. It is loading after a few seconds, and then it is loading all the times. But this is not what I want. I just need to get a solution.

Maybe there is something wrong in the Pagination and Sliders Settings or in the Custom Search Settings.

Regards,

#1351677

Nigel
Supporter

Les langues: Anglais (English ) Espagnol (Español )

Fuseau horaire: Europe/London (GMT+01:00)

Something odd with the caching, because when I visited the page the section had the CSS display:none rule set.

In any case, what you describe I would say is expected.

You have turned on automatic pagination that shows 20 results at a time, updating after every 5 seconds.

So, on your initial page load, the condition—which is essentially checking if this is the first time the View has loaded—fails and nothing is shown.

Then after 5 seconds the page updates with automatic pagination, and so now this is not the first time the View loaded, and hence the results are shown.

You could use a similar technique with the wpv-conditional shortcodes, but you would have to add a test for each of the filters you include in the search form (the existing test is for a generic parameter that is added whenever the View results are updated, including with pagination).

Or you could use the wpv_filter_query API filter where you modify the query to return no results unless a search term is specified, which is probably the best solution in this case where you are automatically paginating results, the only limitation being that you need to remove the "No items found" text, so that nothing would be displayed if someone performed a search and there were no results found.

I can help with that if that sounds okay...

Ce ticket est maintenant fermé. Si vous êtes un client de Toolset et que vous avez besoin d'aide, veuillez ouvrir un nouveau ticket d'assistance