From: Anthony Talarico Date: Wed, 3 May 2017 16:11:14 +0000 (-0400) Subject: adding pagination to search results X-Git-Tag: v1.0.0^2~98 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=04f895d869378fbe29f058af5eded9b84841b9d0;p=WP-Themes%2Fmichigantrailmaps.git adding pagination to search results adding the query params filter to the functions file and adding the filter to the list page to apply the query params in the search fields for pagination --- diff --git a/functions.php b/functions.php index e3bd6eb..8a2196f 100644 --- a/functions.php +++ b/functions.php @@ -67,6 +67,36 @@ add_filter('glm-member-db-front-search-query', function( $queryParts ) { } return $queryParts; }); +add_filter('glm-member-db-fields-front-list-query-params', function( $query ){ + $queryParams = array(); + // Check for manufactures + if ( isset( $_REQUEST['categories'] ) && is_array( $_REQUEST['categories'] ) ) { + foreach ( $_REQUEST['categories'] as $man ) { + $queryParams[] = "categories[]={$man}"; + } + } + // This needs to be done for now until it is in the main plugin. + if ( isset( $_REQUEST['counties'] ) && is_array( $_REQUEST['counties'] ) ) { + foreach ( $_REQUEST['counties'] as $cat ) { + $queryParams[] = "counties[]={$cat}"; + } + } + if ( isset( $_REQUEST['cities'] ) && is_array( $_REQUEST['cities'] ) ) { + foreach ( $_REQUEST['cities'] as $cat ) { + $queryParams[] = "cities[]={$cat}"; + } + } + if ( isset( $_REQUEST['regionUserSearch'] ) && is_array( $_REQUEST['regionUserSearch'] ) ) { + foreach ( $_REQUEST['regionUserSearch'] as $cat ) { + $queryParams[] = "regionUserSearch[]={$cat}"; + } + } + if ( isset( $_REQUEST['textSearch'] ) ) { + $cat = filter_var($_REQUEST['textSearch']); + $queryParams[] = "textSearch={$cat}"; + } + return ( !empty( $queryParams ) ? $query . '&'.implode( '&', $queryParams): $query); +},10, 1); /** * Return the client info option for the given key * diff --git a/glm-member-db/views/front/members/list.html b/glm-member-db/views/front/members/list.html index b08b823..9ef8cdf 100644 --- a/glm-member-db/views/front/members/list.html +++ b/glm-member-db/views/front/members/list.html @@ -208,13 +208,16 @@ {/if} {if $paging} +
showing {$start} through {$lastDisplayed} of {$filteredMembersFound}
- Next page - Previous page + Previous page + Next pagea={$alphaSelected}" class="glm-alpha-link" {if !$prevStart} style="pointer-events: none; opacity: 0.5;"{/if}>Previous page
+ + showing {$start} through {$lastDisplayed} of {$filteredMembersFound} {/if}