Fixing page number during search

This commit is contained in:
Will Bradley 2014-02-26 19:38:03 -07:00
parent 7b0a0ecd16
commit b86558764c
2 changed files with 10 additions and 12 deletions

View File

@ -207,7 +207,7 @@ if ( !class_exists( 'Simple_Map' ) ) {
$country_value = get_query_var( 'location_search_country' ); $country_value = get_query_var( 'location_search_country' );
$radius_value = isset( $_REQUEST['location_search_distance'] ) ? $_REQUEST['location_search_distance'] : $radius; $radius_value = isset( $_REQUEST['location_search_distance'] ) ? $_REQUEST['location_search_distance'] : $radius;
$limit_value = isset( $_REQUEST['location_search_limit'] ) ? $_REQUEST['location_search_limit'] : $limit; $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; $is_sm_search = isset( $_REQUEST['location_is_search_results'] ) ? 1 : 0;
// Normal Field inputs // Normal Field inputs
@ -890,7 +890,12 @@ if ( !class_exists( 'Simple_Map' ) ) {
searchData.lat = document.getElementById('location_search_default_lat').value; searchData.lat = document.getElementById('location_search_default_lat').value;
searchData.lng = document.getElementById('location_search_default_lng').value; searchData.lng = document.getElementById('location_search_default_lng').value;
searchData.limit = document.getElementById('location_search_limit').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; searchData.searching = document.getElementById('location_is_search_results').value;
// Do SimpleMap Taxonomies // Do SimpleMap Taxonomies
@ -957,10 +962,6 @@ if ( !class_exists( 'Simple_Map' ) ) {
searchData.limit = 0; searchData.limit = 0;
} }
if ( searchData.page == '' || searchData.page == null ) {
searchData.page = 0;
}
if ( searchData.radius == '' || searchData.radius == null ) { if ( searchData.radius == '' || searchData.radius == null ) {
searchData.radius = 0; searchData.radius = 0;
} }
@ -2213,7 +2214,6 @@ if ( !class_exists( 'Simple_Map' ) ) {
$vars[] = 'location_search_zip'; $vars[] = 'location_search_zip';
$vars[] = 'location_search_distance'; $vars[] = 'location_search_distance';
$vars[] = 'location_search_limit'; $vars[] = 'location_search_limit';
$vars[] = 'location_search_page';
$vars[] = 'location_is_search_results'; $vars[] = 'location_is_search_results';
return $vars; return $vars;
@ -2298,10 +2298,6 @@ if ( !class_exists( 'Simple_Map' ) ) {
if ( '' == $atts['limit'] ) if ( '' == $atts['limit'] )
$atts['limit'] = $options['results_limit']; $atts['limit'] = $options['results_limit'];
//Make sure we have page
if ( '' == $atts['page'] )
$atts['page'] = $options['results_page'];
// Clean search_field_cols // Clean search_field_cols
if ( 0 === absint( $atts['search_form_cols'] ) ) if ( 0 === absint( $atts['search_form_cols'] ) )
$atts['search_form_cols'] = $default_atts['search_form_cols']; $atts['search_form_cols'] = $default_atts['search_form_cols'];
@ -2371,7 +2367,6 @@ if ( !class_exists( 'Simple_Map' ) ) {
'units' => '', 'units' => '',
'radius' => '', 'radius' => '',
'limit' => '', 'limit' => '',
'page' => '',
'autoload' => '', 'autoload' => '',
'zoom_level' => '', 'zoom_level' => '',
'map_type' => '', 'map_type' => '',

View File

@ -118,6 +118,9 @@ if ( !class_exists( 'SM_XML_Search' ) ){
$total_locations = absint($total_locations_sql); $total_locations = absint($total_locations_sql);
$total_pages = ceil($total_locations / $limit_int); // use ceiling to round up -- 0.01 is still "1 page" $total_pages = ceil($total_locations / $limit_int); // use ceiling to round up -- 0.01 is still "1 page"
$this_page_number = absint($input['page']); $this_page_number = absint($input['page']);
if($this_page_number < 1) {
$this_page_number = 1;
}
$sql = "SELECT $sql = "SELECT