hellomoto Posted May 19, 2017 Share Posted May 19, 2017 I have this $selector = 'template=boat_vessel, sort=-boat_date_list, limit=3, '; $selected = [ "make" => "", "hulls" => "", "mobility" => "", //"make/model" => "", "year" => "", "price" => "", "length" => "", "location" => "", //"keywords" => "", ]; if($input->get->make) { $selected["make"] = $sanitizer->text($input->get->make); $selector .= "boat_model|boat_manufacturer*=" . $selected["make"]; } if($input->get->hulls) { $p = $pages->get('name=hulls, parent.name=options')->child('name=' . $sanitizer->pageName($input->get->hulls)); if($p->id) { $selector .= "boat_model.mamo_hulls=$p, "; $selected["hulls"] = $p->title; $input->whitelist("hulls", $p->name); } } if($input->get->mobility) { $p = $pages->get('name=mobility, parent.name=options')->child('name=' . $sanitizer->pageName($input->get->mobility)); if($p->id) { $selector .= "boat_model.mamo_mobility=$p, "; $selected["mobility"] = $p->title; $input->whitelist("mobility", $p->name); } } if($input->get->price_min || $input->get->price_max) { $selector .= "boat_price_list>={$input->get->price_min}, boat_price_list<={$input->get->price_max}, "; $selected["price"] = "{$input->get->currency} {$input->get->price_min} - {$input->get->price_max}"; } if($input->get->length_min || $input->get->length_max) { $selector .= "boat_model.mamo_length_ft>={$input->get->length_min}, boat_model.mamo_length_ft<={$input->get->length_max}, "; $selected["length"] = "{$input->get->length_min} - {$input->get->length_max} ft."; } $form = ''; $form .= '<p> <label for="search_make">Manufacturer/Model</label> <input name="make" id="search_make" type="text" value="'.$selected["make"].'"/> </p>'; // manufacturer/model // make $form .= '<p> <label for="search_hulls">Hull Configuration</label> <select name="hulls" id="search_hulls"> <option value=""></option>'; foreach($pages->get('name=hulls, parent.name=options')->children() as $i) { if($selected['hulls'] == $i->title) $select = ' selected'; else $select = ''; $form .= '<option value="'.$i->name.'"'.$select.'>'.$i->title.'</option>'; } $form .= '</select> </p>'; $form .= '<p> <label for="search_mobility">Mobility</label> <select name="mobility" id="search_mobility"> <option value=""></option>'; foreach($pages->get('name=mobility, parent.name=options')->children() as $i) { if($selected['mobility'] == $i->title) $select = ' selected'; else $select = ''; $form .= '<option value="'.$i->name.'"'.$select.'>'.$i->title.'</option>'; } $form .= '</select> </p>'; $form .= '<p> <label>Price</label> <input type="number" name="price_min" id="search_price_min" style="width:80px" placeholder="Minimum" value="'.$input->get->price_min.'"/> <input type="number" name="price_max" id="search_price_max" style="width:80px" placeholder="Maximum" value="'.$input->get->price_max.'"/> <select name="currency" id="search_currency">'; foreach($pages->get('name=currency, parent.name=options')->children() as $i) { $form .= '<option value="'.$i->title.'">'.$i->title.'</option>'; } $form .= '</select> </p>'; $form .= '<p> <label>Length (feet)</label> <input type="number" name="length_min" id="search_length_min" style="width:50px" placeholder="Min." value="'.$input->get->length_min.'"/> <input type="number" name="length_max" id="search_length_max" style="width:50px" placeholder="Max." value="'.$input->get->length_max.'"/> </p>'; $sidebar .= '<form id="boat_search" method="get" action="'.$pages->get("template=listings")->url.'"> <h2>Search Listings</h2>' .$form. '<input type="submit" id="search_submit" value="Search"/> </form>'; // add reset/clear button $sidebar .= '<br>'.implode('<br>', array_filter($selected)); $results = $pages->find($selector); foreach($results as $i) { $content .= '<h3>'.$i->title.'</h3> '; } $content = "<ol>$content</ol>"; $content .= $results->renderPager(array( 'nextItemLabel' => "Next", 'previousItemLabel' => "Prev", 'listMarkup' => "<ul class='MarkupPagerNav'>{out}</ul>", 'itemMarkup' => "<li class='{class}'>{out}</li>", 'linkMarkup' => "<a href='{url}'><span>{out}</span></a>", 'numPageLinks' => 999, )); This produces accurate search results and paginates effectively without searching; but the search results don't paginate. When the search results overflow a single page, and you go to page 2, it just shows the default second page of all the original results, no search filter. How do I paginate the search results? Link to comment Share on other sites More sharing options...
hellomoto Posted May 19, 2017 Author Share Posted May 19, 2017 Search URL looks like http://localhost/site/en/listings/?make=&hulls=&mobility=&price_min=&price_max=¤cy=%24&length_min=&length_max=&sort=-boat_date_list but then next page of results goes http://localhost/site/en/listings/page2 Link to comment Share on other sites More sharing options...
hellomoto Posted May 21, 2017 Author Share Posted May 21, 2017 Bumper Link to comment Share on other sites More sharing options...
tpr Posted May 21, 2017 Share Posted May 21, 2017 My best guess is you need to add getVars: https://processwire.com/api/modules/markup-pager-nav/ (in other words read the fascinating manual ) 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now