From: Anthony Talarico Date: Wed, 5 Apr 2017 19:23:36 +0000 (-0400) Subject: adding search results query string replacer in js, to change the search results limit... X-Git-Tag: v1.0.0^2~6 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=c27a901e0fe3bfd2a2c028ba4a502c5bc19bba47;p=WP-Plugins%2Fglm-member-db-obits.git adding search results query string replacer in js, to change the search results limit with pagination --- diff --git a/js/front.js b/js/front.js index e330ca8..0ba9db3 100644 --- a/js/front.js +++ b/js/front.js @@ -1,4 +1,6 @@ $(document).ready(function(){ + var next_link = $('.next-link'); + var prev_link = $('.prev-link'); $(".expand-collapse").on("click", function(e){ if( $(this).text() === "Show Options" ){ @@ -64,7 +66,23 @@ $(document).ready(function(){ }); $('#results-limit').on('change', function(){ -// $('#obits-search').submit(); + + var limit = $(this).val(); + var next_url = next_link.attr('href') ; + var prev_url = prev_link.attr('href'); + + var extract = next_url.match(/results-limit=\d+/).pop(); + + var query = extract.match(/results-limit=/).pop(); + var new_query = query + limit; + + // replace the href strings, preparing to replace the actual el href + next_url = next_url.replace(extract, new_query); + prev_url = prev_url.replace(extract, new_query); + + //replace the urls with the new results limit + next_link.attr('href', next_url); + prev_link.attr('href', prev_url); }); $('.print-results-link, .detail-print-results-link').on("click", function(e){ diff --git a/models/front/obits/search.php b/models/front/obits/search.php index a8e6948..4aafdf6 100644 --- a/models/front/obits/search.php +++ b/models/front/obits/search.php @@ -114,7 +114,7 @@ class GlmMembersFront_obits_search extends GlmDataObits $logic_dropdown = array('Contains' => 'LIKE' ,'Starts With' => 'LIKE%','Equals' => '=', 'More than' => '>', 'Less than' => '<'); $per_page = isset( $_REQUEST['results-limit']) ? (int)filter_var( $_REQUEST['results-limit'], FILTER_SANITIZE_STRING) : 50; -// echo $per_page; + // only execute search if the search button is clicked or there are search params in the url if ( isset( $_REQUEST['searchButton'] ) || !empty( $_GET['alpha'] ) || !empty( $_GET['pageSelect'] ) ){ diff --git a/views/front/obits/searchResults.html b/views/front/obits/searchResults.html index c942d44..28df080 100644 --- a/views/front/obits/searchResults.html +++ b/views/front/obits/searchResults.html @@ -226,9 +226,9 @@ {if $paging}
- Previous page + Previous page - Next page + Next page
showing {$start} through {$lastDisplayed} of {$total}
@@ -295,6 +295,7 @@