From b86558764ccd5428a96f23f0652bba2ca3dbcec6 Mon Sep 17 00:00:00 2001 From: Will Bradley Date: Wed, 26 Feb 2014 19:38:03 -0700 Subject: [PATCH] Fixing page number during search --- classes/simplemap.php | 19 +++++++------------ classes/xml-search.php | 3 +++ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/classes/simplemap.php b/classes/simplemap.php index 9e01058..9ede872 100755 --- a/classes/simplemap.php +++ b/classes/simplemap.php @@ -207,7 +207,7 @@ if ( !class_exists( 'Simple_Map' ) ) { $country_value = get_query_var( 'location_search_country' ); $radius_value = isset( $_REQUEST['location_search_distance'] ) ? $_REQUEST['location_search_distance'] : $radius; $limit_value = isset( $_REQUEST['location_search_limit'] ) ? $_REQUEST['location_search_limit'] : $limit; - $page_value = get_query_var( 'location_search_page' ); + $page_value = $_REQUEST['location_search_page']; $is_sm_search = isset( $_REQUEST['location_is_search_results'] ) ? 1 : 0; // Normal Field inputs @@ -890,7 +890,12 @@ if ( !class_exists( 'Simple_Map' ) ) { searchData.lat = document.getElementById('location_search_default_lat').value; searchData.lng = document.getElementById('location_search_default_lng').value; searchData.limit = document.getElementById('location_search_limit').value; - searchData.page = document.getElementById('location_search_page').value; + if(is_search == 1){ + searchData.page = 0; + } + else { + searchData.page = document.getElementById('location_search_page').value; + } searchData.searching = document.getElementById('location_is_search_results').value; // Do SimpleMap Taxonomies @@ -957,10 +962,6 @@ if ( !class_exists( 'Simple_Map' ) ) { searchData.limit = 0; } - if ( searchData.page == '' || searchData.page == null ) { - searchData.page = 0; - } - if ( searchData.radius == '' || searchData.radius == null ) { searchData.radius = 0; } @@ -2213,7 +2214,6 @@ if ( !class_exists( 'Simple_Map' ) ) { $vars[] = 'location_search_zip'; $vars[] = 'location_search_distance'; $vars[] = 'location_search_limit'; - $vars[] = 'location_search_page'; $vars[] = 'location_is_search_results'; return $vars; @@ -2298,10 +2298,6 @@ if ( !class_exists( 'Simple_Map' ) ) { if ( '' == $atts['limit'] ) $atts['limit'] = $options['results_limit']; - //Make sure we have page - if ( '' == $atts['page'] ) - $atts['page'] = $options['results_page']; - // Clean search_field_cols if ( 0 === absint( $atts['search_form_cols'] ) ) $atts['search_form_cols'] = $default_atts['search_form_cols']; @@ -2371,7 +2367,6 @@ if ( !class_exists( 'Simple_Map' ) ) { 'units' => '', 'radius' => '', 'limit' => '', - 'page' => '', 'autoload' => '', 'zoom_level' => '', 'map_type' => '', diff --git a/classes/xml-search.php b/classes/xml-search.php index 7f661e9..61e8361 100755 --- a/classes/xml-search.php +++ b/classes/xml-search.php @@ -118,6 +118,9 @@ if ( !class_exists( 'SM_XML_Search' ) ){ $total_locations = absint($total_locations_sql); $total_pages = ceil($total_locations / $limit_int); // use ceiling to round up -- 0.01 is still "1 page" $this_page_number = absint($input['page']); + if($this_page_number < 1) { + $this_page_number = 1; + } $sql = "SELECT