Member
Member
flu   2011-02-17, 17:44
#1

Hi,
when using search and nothing is found, wouldn't it be nice to clear the search field ?

Anyway, is there any trick to clear the search field in any case ?

Cheers !

Member
Member
sbillard   2011-02-17, 20:07
#2

There should be a reset button to clear the field. Or do you mean programatic trick?

Member
Member
flu   2011-02-17, 21:08
#3

That's it, I mean programatic trick.
Anyway - IMHO - I thought that my first request (if no result found) would get sense.

Cheers !

Member
Member
sbillard   2011-02-17, 21:53
#4

$_zp_current_search->setSearchParams('words=');

This has to be done in the theme itself as the theme is the only entity that knows if the search was empty. We can add that to the standard themes.

Member
Member
flu   2011-02-17, 22:01
#5

Thank you Stephen, I'll try it.

Member
Member
flu   2011-02-18, 17:16
#6

Stephen,
could you please tell me where to write it in search.php ?
I'm a bit lost.

Cheers.

Member
Member
sbillard   2011-02-18, 18:44
#7

First, turns out that is not sufficient. (The search engine caches the search!)

So what you need to do is place the following code in search.php somewhere before the call on printSearchForm()

$_zp_current_search->processed_search = ''; $_zp_current_search->words = '';
Of course, do this only if there have your page determines there are no results.

Member
Member
flu   2011-02-20, 15:02
#8

That works.
A big thank you, Stephen !

Cheers !

Member
Member
sbillard   2011-02-20, 22:53
#9

This will become a feature next release for distributed themes. There will be an object method to clear the search parameters.

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.