Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Double-click advanced search


Guest

Recommended Posts

My store is a DVD rental joint, and I couldn't find a way to link all the cast and crew names in some sort of database so you could click on a name and be shown all the films on my site an actor appears in. Just like

the IMDB. If anyone knows how to do that please tell me.

 

So I came up with a workaround, I adapted the following javascript which lets you double-click on any word on the product page and it will do an advanced search in descriptions on that word. Problem is double-clicking only selects one word at a time, so I have to take out the space between names like this: MelGibson and it works wonderfully. I just put a tip on the product page about searching using this method, your shop needn't be a DVD store for this. It also works well with the "javascript "back" button" contribution.

 

So here it is:

 

Open /catalog/product_info.php and in the head section right below the title add this:

 

<script LANGUAGE="JavaScript">
<!-- Begin double click advanced search
var NS = (navigator.appName == "Netscape") ? 1 : 0;
if (NS) document.captureEvents(Event.DBLCLICK);
document.ondblclick = dict;

var newwin;
function dict() {
if (NS) {
t = document.getSelection();
opennewwin(t);
}
else {
t = document.selection.createRange();
if(document.selection.type == 'Text' && t.text != '') {
document.selection.empty();
opennewwin(t.text);
  }
  }}
function opennewwin(text) {
if (text > '') {
window = document.replace(self.location.href='/catalog/advanced_search_result.php?search_in_description=1&keywords='+text);
  }
}
//  End double click advanced search-->
</script>

Link to comment
Share on other sites

I just discovered that to select 2 words or first and last names you can double click right at the very start of the first letter of the last word/name. Once you get the hang of it it's easy!

Link to comment
Share on other sites

But wait there's more! I discovered IE doesn't work like Firefox, so here's a version of the script that works by selecting any text you want to search and pressing a key, preferably the Ctrl key.

So here we go again,

 

Add the following to /catalog/product_info.php in the head section just under the title:

 

<script LANGUAGE="JavaScript">
<!-- Begin selection advanced search
var NS = (navigator.appName == "Netscape") ? 1 : 0;
if (NS) document.captureEvents(Event.DBLCLICK);
document.onkeydown = dict;

var newwin;
function dict() {
if (NS) {
t = document.getSelection();
opennewwin(t);
}
else {
t = document.selection.createRange();
if(document.selection.type == 'Text' && t.text != '') {
document.selection.empty();
opennewwin(t.text);
  }
  }}
function opennewwin(text) {
if (text > '') {
window = document.replace(self.location.href='/catalog/advanced_search_result.php?search_in_description=1&keywords='+text);
  }
}
//  End selection advanced search-->
</script>

 

This should work much better and should be crossbrowser compatible, I've tried it on Firefox and IE.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...