Sat 28 Mar |
|
An A to Z, 0 to 9 (Alpha-numeric) search/listing module for VirtueMart.Search for VirtueMart products by first letter or number and display the results in the standard VirtueMart search results page. If only one result is found it redirects to the product page. You can try it here - Demo ... and download it here - Download How it works -It just utilises the standard Virtuemart search but filters it by product name and 1st letter or number.It needs the installation of this module and two very small hacks in classes/ps_main.php and html/shop_browse_queries.php The module installs as normal and publish it somewhere. The only only parameters are pre and post text and module classes. It's simply a list of search urls and is very simple to style differently directly in the mod_az_virtuemart.php file or with css. StylingGive the module a class then style the resulting menu classa.mainlevel-az {
... An image for each letter would be even better.padding-left:5px; text-decoration:none; } Source Changes NeededThe change needed to html/shop_browse_queries.php is to make a new $search_limiter parameter so it only searches for the 1st letter.around line 110 insert after switch($search_limiter) { case "az":
so it looks like
$sq .= "\n `#__{vm}_product`.`product_name` LIKE '$searchstring%' "; break; switch($search_limiter) {
In the file classes/ps_main.php the function "vmGetCleanArrayFromKeyword" ignores the search unless there's more than 2 letters.case "az": $sq .= "\n `#__{vm}_product`.`product_name` LIKE '$searchstring%' "; break; case "name": $sq .= "\n `#__{vm}_product`.`product_name` LIKE '%$searchstring%' "; break; I change this to 1 letter to get it to work. I tried to use a different keyword parameter e.g. keyword3 but I couldn't get it to work but this would be a "nicer" way to do it rather than hook in to the already used parameter. Perhaps someone can achieve this? So in classes/ps_main.php around the line 1260 change the if( $strlen > 2 ) {
to
if( $strlen > 0 ) {
Updates!Version 0.2 Code re-written so that the urls are formed by php, a smaller package now (ver0.2) Version 0.3 Fixed problem with search urls and SEF components If you have any comments, suggestions or need any help please leave a comment below. If you use it on a commercial site (if it's Virtuemart I guess it's got to be commercial ;) ) please leave a small donation. Thanks. |
Last Updated on Saturday, 12 December 2009 12:20 |