clear the search field if no results found

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 !

Comments

  • There should be a reset button to clear the field. Or do you mean programatic trick?
  • That's it, I mean programatic trick.
    Anyway - IMHO - I thought that my first request (if no result found) would get sense.

    Cheers !
  • `$_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.
  • Thank you Stephen, I'll try it.
  • Stephen,
    could you please tell me where to write it in search.php ?
    I'm a bit lost.

    Cheers.
  • 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.
  • That works.
    A big thank you, Stephen !

    Cheers !
  • This will become a feature next release for distributed themes. There will be an object method to clear the search parameters.
Sign In or Register to comment.