Skip Navigation

[Resolved] En una vista no muestre resultados , hasta que no utilizen el buscador

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.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 6 replies, has 1 voice.

Last updated by Rafael Corts 2 days, 21 hours ago.

Assisted by: Minesh.

Author
Posts
#2810419

Tengo una "Vista" con un filtro de búsqueda, lo que quiero es que muestre el campo de búsqueda, pero no muestre ningún resultado hasta que el usuario no escriba nada en el buscador.
Solo muestre los resultados, mientras que no aparezca nada.
¿Cómo lo podría hacer?
Saludos.
Rafa Corts

#2810420

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

As you already know - Spanish support is not available at the moment and I will try to guidke you in English. Hope this is OK.

Can you please tell me are you using Block view or legacy/classic view?

#2810424
tipo-de-vista.jpg

Hola Minesh,
Creo que estoy utilizando la vista clasica.
te adjunto una imagen para que puedas ver como lo tengo configurado
Saludos.
Rafa Corts

#2810536

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

what if you try to add the following code to "Custom Code" section offered by Toolset:
=> => https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/

add_filter( 'wpv_filter_query', 'func_display_no_result_by_default', 10, 3 );
function func_display_no_result_by_default( $query_args, $setting,$view_id ) {
    if($view_id == 99999) {
 
         if(!isset($_REQUEST['wpv_filter_submit'])) {
            $query_args['post__in'] = array(0);
        }
    }
    return $query_args;
}

Where:
- Please replace 9999 with your original view ID

Can you plese confirm it works?

#2810667

Hola Minesh, no acaba de funcionar el codigo, en principio desaparece todo el listado de conferencias (esto es correcto) pero cuando haces una busqueda no mustra ningun resultado. Si quieres acceder me lo dices para que puedas comprobar que es lo que sucede.
Saludos.
Rafa Corts

#2810669

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Yes Please.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2810754

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please check now: hidden link

I've adjusted the code added to "Custom Code" section as given under:
=> hidden link

add_filter( 'wpv_filter_query', 'func_display_no_result_by_default', 10, 3 );
function func_display_no_result_by_default( $query_args, $setting,$view_id ) {
    if($view_id == 129) {
      
      if($_SERVER['REQUEST_METHOD'] === 'POST'){
        
        if(!isset($_POST['search'])){
          	 $query_args['post__in'] = array(0);
        }
        
     }else{
        	 $query_args['post__in'] = array(0);
     }
      
        
    }
    return $query_args;
}

Can you please confirm it works as expected.

#2811105

Perfecto!!
Muchas gracias.
Rafa Corts