Gossamer Forum
Home : Products : Links 2.0 : Customization :

Choice of searches

Quote Reply
Choice of searches
Hi!

Would it be possible to create a search form where you could specify which search engine you wish to use. For example, the visitor could have a choice of searching your links directory or for books at amazon.com (with your unique associates ID in it), using radio buttons. It would probably require a separate script or something. Any ideas will be greatfully received!
Quote Reply
Re: Choice of searches In reply to
Funny, I was just working on this, too...
http://www.gossamer-threads.com/...um3/HTML/001867.html
Quote Reply
Re: Choice of searches In reply to
Yeah, I've found a good script that works. It's at http://anaconda.net/ap_director.shtml
Quote Reply
Re: Choice of searches In reply to
that's cool. I just did a search engine chooser in JavaScript last night:

<script language="JavaScript">
<!--
// determine which engine to search
function doSearch() {
if (search.engine.value=="1")
{search.action="http://ucmd.virtualave.net/cgi-bin/artist/search.cgi";}
if (search.engine.value=="2")
{search.action="http://ucmd.virtualave.net/cgi-bin/radio/search.cgi";}
if (search.engine.value=="3")
{search.action="http://ucmd.virtualave.net/cgi-bin/record/search.cgi";}
}
// end script
-->
</script>
<form name="search" method="get">
<input name="query" size="30" ><br>
<select name="engine" size="1" onChange="doSearch();" >
<option>Choose Database</option>
<option value="1">Artist</option>
<option value="2">Radio Station</option>
<option value="3">Record Label</option>
</select><br>
<INPUT name="Submit" type="submit" value="Submit">
</form>
Quote Reply
Re: Choice of searches In reply to
Funny, but I couldn't get your original javascript code to work. Here's how I modified your code to work so that you can search two separate links.db from one search form:

<script type="text/javascript">
function doSearch() {
if (search.engine.value=="1")
{search.action="http://ucmd.virtualave.net/cgi-bin/artist/search.cgi";}
if (search.engine.value=="2")
{search.action="http://ucmd.virtualave.net/cgi-bin/radio/search.cgi";}
if (search.engine.value=="3")
{search.action="http://ucmd.virtualave.net/cgi-bin/record/search.cgi";}
}
</script>

<form name="search" method="get">
<input name="query" size="30" >

<select name="engine" size="1" onChange="doSearch();" >
<option>Choose Database</option>
<option value="1">Artist</option>
<option value="2">Radio Station</option>
<option value="3">Record Label</option>
</select>

<INPUT name="Submit" type="submit" value="Submit">
</form>

-------

OK, hold the presses. After cross browser testing I have found that my version of your script does not work under netscape 4.x. It does work under IE 4.x+



Quote Reply
Re: Choice of searches In reply to
Use Perl! Server-side languages always better...searching across different databases/engines has been discussed many times in this forum and Mods have also been written and referenced in the Resources section.

Like the following:

http://lookhard.hypermart.net/links-mods/

Regards,

Eliot Lee
Quote Reply
Re: Choice of searches In reply to
Yeah - I agree. I'm not a fan of javascript for a whole lot of reasons - and I feel that using any languages that you know will restrict some of your site's visitors is downright foolish (that's why I avoid Java, too). Perl is definitely a beautiful thing :)

As for searching multiple DB's, I prefer using Anaconda Director (v1.3) - along with links 2.0 search modified with the multiple field search mod and the alternating background color mod (in search results).

The great thing about Anaconda is that you can pass along form fields/variables via your form or you can include form field variables in the anaconda script itself to force search values.

One thing to remember with Anaconda (when using to search a Links DB) is to change $AP_script_substitutions to "search=query" and the $AP_script_mode to "GET"

-------------

The multi field search mod I found in the forums went something like this:

In search.cgi, before the line:

# Check to see if the link matches.

Add:

$searchonly = $in{'searchonly'};

if ($searchonly eq "all") {
@search_fields = (1,4,5,6,15,17);
}
if ($searchonly eq "Field 1") {
@search_fields = (1);
}
if ($searchonly eq "Field 4") {
@search_fields = (4);
}
if ($searchonly eq "Field 5") {
@search_fields = (5);
}
if ($searchonly eq "Field 17) {
@search_fields = (17);
}

Change the field #'s above to match the ones in links.def that you want searched. Then in your search.html template, add something like this (with corresponding fields from above):

<P><b>Confine Search To:</b></p>
<P>
Entire Database: <input type="RADIO" name="searchonly" value="all" checked>

Field 1: <input type="RADIO" name="searchonly" value="Field 1">

Field: 4 <input type="RADIO" name="searchonly" value="Field 4">

Field: 5 <input type="RADIO" name="searchonly" value=" Field 5">

Field: 17 <input type="RADIO" name="searchonly" value="Field 17">

</p>


----------------------------

Here's the alternating BGCOLOR modification code I found here:


In site_html_templates.pl find sub site_html_link.

ADD CODE:

($bgcolor && $bgcolor eq "#ffffff") ? ($bgcolor = "#eeeeee") : ($bgcolor = "#ffffff");


the code goes before this line


CODE:

---------------------

return &load_template ('link.html', {

---------------------

and this is needed too


ADD CODE:
---------------------

bgcolor => $bgcolor,

somewhere above %globals in sub site_html_link

---------------------

use <%bgcolor%> in your table in link.html template..

in this example.. the first color would be ffffff..
then the second color would be eeeeee..
the first color needs to be implemented twice..
once in the first and third one and the second color needs to be in the second one..


--------------

Ciao



Quote Reply
Re: Choice of searches In reply to
Quick suggestion you should use if else statements instead of a load of if statements...

Also you could instead use:


if (!$in{'searchonly'}){
@search_fields = (1,4,5,6,15,17);
}
else {
@search_fields = ($in{'searchonly'});
}

And have the radio fields like:

Field: 17 <input type="RADIO" name="searchonly" value="7">


Ie. if no radio boxes are checked it'll go thru all the fields specified...




Glenn

Links 2 Mods Site:
http://cgi-resource.co.uk/pages/links2mods.shtml
Quote Reply
Re: Choice of searches In reply to
 
Thanks for the heads up on that. I'm pretty sure you can also set it up with checkboxes instead of radio and use elseif's. Something like:

if ($searchonly eq "all") {
@search_fields = (1,4,5,6,15,17);
}
elsif ($searchonly eq "Field 1") {
@search_fields = (1);
}
elsif ($searchonly eq "Field 4") {
@search_fields = (4);
}
elsif ($searchonly eq "Field 5") {
@search_fields = (5);
}
elsif ($searchonly eq "Field 17") {
@search_fields = (17);
}
else {
@search_fields = (1,4,5,6,15,17);
}

Then people could limit the search to more than one specific field...

Also, I forgot to mention the subcategories search (by Jose Reffoios). That adds a lot of zing to the old search-a-roo. You can use all of them to make one helluva advanced search page.

Quote Reply
Re: Choice of searches In reply to
You don't need to use:

if ($searchonly eq "all") {
@search_fields = (1,4,5,6,15,17);
}



Glenn

Links 2 Mods Site:
http://cgi-resource.co.uk/pages/links2mods.shtml
Quote Reply
Re: Choice of searches In reply to
... because it's already covered in the else at the end. You da man. So it should just start with:

if ($searchonly eq "Field 1") {
@search_fields = (1);
}