WP Residence Help WP Residence Help

  • WpEstate
  • How to Build Your Website
  • Video Tutorials
  • Client Support
  • API
Home / Technical how to | Custom Code Required / Technical how to: Advanced Search explained – advanced search forms

Technical how to: Advanced Search explained – advanced search forms

3110 views 0

How advanced search forms are displayed

The advanced search forms are displayed via advanced_search.php. Here we load different templates accordingly to the what type of search you selected.
if ($adv_search_type==1){
include(locate_template('templates/advanced_search_type1.php'));
}else if ($adv_search_type==3){
include(locate_template('templates/advanced_search_type3.php'));
}else if ($adv_search_type==4){
include(locate_template('templates/advanced_search_type4.php'));
}else if ($adv_search_type==5){
include(locate_template('templates/advanced_search_type5.php'));
}else if ($adv_search_type==6){
include(locate_template('templates/advanced_search_type6.php'));
}else if ($adv_search_type==7){
include(locate_template('templates/advanced_search_type7.php'));
} else if ($adv_search_type==8){
include(locate_template('templates/advanced_search_type8.php'));
} else if ($adv_search_type==9){
include(locate_template('templates/advanced_search_type9.php'));
}else if ($adv_search_type==10){
include(locate_template('templates/advanced_search_type10.php'));
}else if ($adv_search_type==11){
include(locate_template('templates/advanced_search_type11.php'));
}else{
f( !is_tax() && basename ( get_page_template() ) !== 'advanced_search_results.php'){
include(locate_template('templates/advanced_search_type2.php'));
}else{
include(locate_template('templates/advanced_search_type1.php'));
}

Let’s look over advanced_search_type1.php file

Here are 2 situations – when you have default search fields or when you have custom fields.

When you have the default fields the  search fields are loaded via  function wpestate_show_search_field_classic_form

$search_form = wpestate_show_search_field_classic_form('main',$action_select_list,$categ_select_list ,$select_city_list,$select_area_list);

The wpestate_show_search_field_classic_form is located in functions.php. Please note that in the beginning of the file we set different classes  or id’s . These are set based on the $position parameter (main – is the main form, sidebar, shortcode, mobile)

if ($postion=='main'){
$caret_class = ' caret_filter ';
$main_class = ' filter_menu_trigger ';
$appendix = '';
$price_low = 'price_low';
$price_max = 'price_max';
$ammount = 'amount';
$slider = 'slider_price';
$drop_class = '';

After that we fill up the $return_string with the default fields – considering the classes and id’s we set in the beginning of the function.

If the search has custom fields then the we use another function inside a foreach that loops trough custom fields.

foreach($adv_search_what as $key=>$search_field){
wpestate_show_search_field('mainform',$search_field,$action_select_list,$categ_select_list,$select_city_list,$select_area_list,$key,$select_county_state_list);
}

The function wpestate_show_search_field() is in help_functions,

Here we are doing the same thing – set some classes and id’s considering the $position parameter  – where we will use the function

after that we create the search form considering the custom fields you selected

if you pick type – see code in if block

else if($search_field=='types'){

 

if you pick categories- see code in if block

}else if($search_field=='categories'){

 

if you pick cities- see code in if block

}  else if($search_field=='cities'){

 

if you pick areas- see code in if block

}   else if($search_field=='areas'){

if you pick county / state – see code in if block

}else if($search_field=='county / state'){

 

if is none of the above see the else branch

}else {

$show_dropdowns = get_option(‘wp_estate_show_dropdowns’,”);

$string = wpestate_limit45 ( sanitize_title ($adv_search_label[$key]) );
$slug = sanitize_key($string);

In the last branch we check if the custom field is a dropdown or not, if is property price ( and display the input forms or slider – see wpestate_price_form_adv_search()  ) , if we have a datepicker etc.

 

 

Beside the main forms described above there are 3 additional search forms

  1. Widget  – located in widgets/advanced_search.php
  2. Shortcode – located in shortcodes.php,  function wpestate_advanced_search_function ()
  3. Mobile  – located in adv_search_mobile.php

All the above search fields use the same functions like  the ones described in advanced_search_type1.php

 

Advanced Search type 2 – with autocomplete

In this case all the forms elements are located in advanced_search_type2.php file.

The most important thing is the autocompletion suggestion list . This is made via jquery ui autcomplete functions at line 84. The suggestion list is $availableTags  and is composed from cities, areas and counties that are already inserted into database.

 

$availableTags='';
$args = array( 'hide_empty=0' );
$terms = get_terms( 'property_city', $args );
foreach ( $terms as $term ) {
$availableTags.= '"'.$term->name.'",';
}

$terms = get_terms( ‘property_area’, $args );
foreach ( $terms as $term ) {
$availableTags.= ‘”‘.$term->name.'”,’;
}

$terms = get_terms( ‘property_county_state’, $args );
foreach ( $terms as $term ) {
$availableTags.= ‘”‘.$term->name.'”,’;
}

 

See also Technical how to: Advanced Search explained – advanced search results page

Technical how to | Custom Code Required

Related Articles

  • Introduction to WPResidence Header Customization
  • Understanding WPResidence Header Types: An Overview
  • Customizing the WPResidence Logo Display
  • Configuring the Primary Navigation Menu in WPResidence

WP Residence Documentation

  • 1. General
    • How to Get Support
    • Get your buyer license code.
    • Use SSL / https
    • Server / Theme Requirements
  • 2. Installation
  • 3. Installation FAQ
  • 4. Advanced Search
    • Advanced Search Display Settings
    • Advanced Search Form
    • Geolocation Search for Half Map
    • Save Search Theme Options
    • Advanced Search Colors
  • 5. Agent, Agency & Developers
  • 6. Property Page
  • 7. Properties List
  • 8. Property Taxonomies
  • 9. Property Custom Template
  • 10. Blog Posts & Blog List
  • 11. Shortcodes
    • Contact Form
    • Featured Agency/Developer
    • Membership Packages
    • Testimonials
    • Google Map with Property Marker
    • Listings per Agent, Agency or Developer
    • Display Categories
    • Agent List
    • Recent Items Slider
    • Recent items
    • List Properties or Articles by ID
    • Featured Agent
    • Featured Article
    • Featured Property
    • Login & Register Form
    • Icon Content Box Shortcode
  • 12. Widgets
  • Theme Options
    • General Settings
    • User Types Settings
    • Appearance
    • Logos & Favicon
    • Header
    • Footer Style and Colors
    • Price & Currency
    • Property Custom Fields
    • Features & Amenities
    • Listing Labels
    • Theme Slider
    • Permalinks
    • Splash Page
    • Social & Contact
    • Map Settings
    • Pin Management
    • How read from file works
    • General Design Settings
    • Custom Colors Settings
    • Header Design & Colors
    • Mobile Menu Colors
    • User Dashboard Colors
    • Print PDF Design
    • Property, Agent, Blog Lists Design Settings
    • Sidebar Widget Design
    • Font management
    • How to add custom CSS
    • Custom Property Card Unit – Beta version
    • Email Management
    • Import & Export theme options
    • reCaptcha settings
    • YELP API Integration
    • iHomefinder Optima Express IDX
    • MEMBERSHIP & PAYMENT Settings
    • Property Submission Page
    • PayPal Setup
    • Stripe Setup
    • Wire Transfer Payment Method
  • Translation
  • FAQ
  • Pages
  • Header
  • Footer
  • Google or Open Street Maps
  • Payment Options
  • Plugins
    • Included Plugins
    • Third Party Plugins – IDX Compatibility
    • Third Party Plugins – Multi Languages
    • Third party Plugins – Other
  • Technical
    • Technical how to | Custom Code Required
    • Technical: Child Theme
  • Theme Updates

Join Us On

Powered by WP Estate - All Rights Reserved
  • WpEstate
  • How to Build Your Website
  • Video Tutorials
  • Client Support
  • API