Skip Navigation

[Resolved] A search view with two “search forms”

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 2 replies, has 1 voice.

Last updated by Minesh 4 weeks, 1 day ago.

Assisted by: Minesh.

Author
Posts
#2866635

Hello,

I want/need/try to build the following. A view with a search. One search form on the index page and one on the result page with the results. I now how to do this: https://toolset.com/course-lesson/displaying-search-results-on-a-different-page/ No problem.

But i need a different search (only one or two selections) on the index page. And a full search on the result page.
There is a site in your "showcase" who has this: hidden link

How can this be done?

Thanks in advance.

#2866638

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Possibally we can use conditional statements to show/hide search filters but I can tell you what would be the best way to do it once I see your existing setup.

Can you please tell me what search filters exactly you want to display on homepage/index page and what search filters you want to display on the search result page.

*** 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.

#2866890

Minesh
Supporter

Languages: English (English )

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

I've added the following function to "Custom Code" section offered by Toolset:
=> hidden link

function ts_is_front_page() {
    return is_front_page() ? 1 : 0;
}

Then I've register that "ts_is_front_page" function at:
=> Toolset => Settings => Front-end Content => Functions inside conditional evaluations

And then with your view, I've set the option "Full page refresh when visitors click on the search button" from "Custom Search Settings" section.
=> hidden link

And wrap the following code with [wpv-conditonal] shortcode within "Search and Pagination":

[wpv-filter-start hide="false"]
[wpv-filter-controls]

<div class="row">
  
 <div class="col">
  <div class="form-group">
	[wpv-filter-search-box placeholder="Plaats, provincie, branche en meer..." output="bootstrap"]
   </div>
  </div>

[wpv-conditional if="(  ts_is_front_page() ne '1' )" ]    
  <div class="col"><div class="form-group">
	<label for="wpv-wpcf-provincie" class="wpv-wpcf-provincie">[wpml-string context="wpv-views"]Provincie[/wpml-string]</label>
	[wpv-control-postmeta type="select" field="wpcf-provincie" default_label="Provincie" url_param="wpv-wpcf-provincie"]
</div></div>
  

  <div class="col"><div class="form-group">
	<label for="wpv-branche" class="wpv-branche">[wpml-string context="wpv-views"]Branche[/wpml-string]</label>
	[wpv-control-post-taxonomy taxonomy="branche" type="select" default_label="Alle" url_param="wpv-branche"]
</div></div>


	<div class="col">
      <div class="form-group">
        [wpv-control-distance default_distance="50" compare_field="map-adres" distance_center_url_param="toolset_maps_distance_center" distance_radius_url_param="toolset_maps_distance_radius" distance_unit_url_param="toolset_maps_distance_unit" inputs_placeholder=" %%DISTANCE%% Of zoek in de buurt van %%CENTER%%"]</div></div>

[/wpv-conditional]
  
  <div class="col"><div class="form-group">[wpv-filter-submit name="Zoeken" output="bootstrap" class="zoeken-btn"]</div></div>
</div>


[/wpv-filter-controls]
[wpv-filter-end]

As you can see the fields are wrapped with conditonal shortcode:

[wpv-conditional if="(  ts_is_front_page() ne '1' )" ]    

 //// your fields

[/wpv-conditional]

More info:
- https://toolset.com/documentation/programmer-reference/views/using-custom-functions-in-conditions/
- https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/