Converting "Order by relevance|price" links to dropdown.
Hi,
I've been struggling to convert the "order by: relevance|price" links that get displayed in the banner on the search page to a simple drop down list of the options instead. It seems like it should be an easy thing to do, but I have managed to achieve all sorts of undesirable effects! Can anyone help me?
Thanks
Zoe
Hi David,
Was going through the various mods posted and came across this one. The drop-down wasn't reloading the page for me so after some googling I found that replacing
JavaScript:this.submit(); with JavaScript:this.form.submit(); seemed to do the trick and its now working ok. I know this is almost 2 years old now but thought it might help out anyone that can't get it working.
Thanks, Jay!
Cheers,
David.
--
Developer, Price Tapestry
General PHP, MySQL and Affiliate Marketing tech help for Price Tapestry customers at davidmorison.com
Hello Zoe,
The sort links are generated by this code in search.php (line 147 in the distribution):
$banner["h3"] = translate("Order by").": ".$sortRelevance.$sortRating." | ".translate("Price").": ".$sortPriceAsc.", ".$sortPriceDesc;To replace the direct links with a form, replace this with:
$sortForm = "";$sortForm .= "Order by: ";
$sortForm .= "<form method='GET' style='display:inline;' action='".$config_baseHREF."search.php'>";
$sortForm .= "<input type='hidden' name='q' value='".htmlentities($q,ENT_QUOTES,$config_charset)."' />";
$sortForm .= "<input type='hidden' name='page' value='1' />";
$sortForm .= "<select name='sort' onchange='JavaScript:this.submit();'>";
$sortForm .= "<option value='relevance' ".($sort=="relevance"?"selected='selected'":"")." >Relevance</option>";
$sortForm .= "<option value='rating' ".($sort=="rating"?"selected='selected'":"")." >Product Rating</option>";
$sortForm .= "<option value='priceAsc' ".($sort=="priceAsc"?"selected='selected'":"")." >Price - Ascending</option>";
$sortForm .= "<option value='priceDesc' ".($sort=="priceDesc"?"selected='selected'":"").">Price - Descending</option>";
$sortForm .= "</select>";
$sortForm .= "<noscript><input type='submit' value='Go' /></noscript>";
$sortForm .= "</form>";
$banner["h3"] = $sortForm;
I've made it so that the currently selected sort order is selected by default in the drop down box. Note the use of style='display:inline;' to keep the form on the same level as the "Order by: " text.
Cheers!
David.