PDA

View Full Version : Adding functionality to default "No results found" page


turnround
19-03-09, 16:35
I would like to add some functionality to what currently happens when a product is searched for but doesn't exist.

For example, if I search for "Indesit WIXL1200OT" (a washing machine) or "Indesit WIXL1200OT washing machine" it just returns an error "No results found...".

This isn't particularly user friendly, so I would like it to offer alternatives if the specific product is not found.

For instance, if "Indesit WIXL1200OT" returns nothing, it would show "Indesit Washing Machines", which does return some results.

If "Indesit Washing Machines" returned nothing, then is should just show results for "washing machines".

This would be far more user-friendly than a blank search results page, and would prompt customers to explore possible alternative products, if the specific one they searched for isn't available.

I've tried passing additional 'manufacturer' and 'product type' variables to the search page, which works, but I am unable to access these variables in the template. They're just blank.

All I'd like to do is provide alternative search links for the specific product type and/or manufacturer underneath the "No results found..." error message.

I've scoured the forums, and tried various things myself, but can't get the variables passed to the template to display.

Any ideas?

Andy
19-03-09, 16:54
to pass a variable to the template you need to use the smarty assign:



$variable = 'my variable';
$oSmarty->assign('variable', $variable);
in smarty template:


Display {$variable} for Gods Sake
would display:

Display my variable for Gods SakeYou can also assign arrays and objects and loop through them in your template, although thats abit more advanced. Have a play with the above and if you find you need to do this, let us know.

Hope this helps

turnround
24-03-09, 11:09
Hi Andy,

Thanks very much for that - it worked perfectly! So simple when you know how!

If I get any further queries about more advanced implementation, I'll post back, but that's given me a good starting point to do what I want.

Cheers!

Andy
25-03-09, 14:28
you're welcome mate, happy to help