Gossamer Forum
Home : Products : Links 2.0 : Installation -- Unix :

$term $query and search yahoo and others

Quote Reply
$term $query and search yahoo and others
Hello Bobsie,
you helped me some days before with my allocation problem. It isnīt solved (yet), but while testing I wonder if itīs possible to get this searching with yahoo, altavista... to work.
I decided to work with templates and the searchterm is not passed over to $term (I also tried $query). I couldnīd find a solution here in the board so I ask for help.
Many thanks in advance
Claus
Quote Reply
Re: $term $query and search yahoo and others In reply to
I am not following this. What are you using to search altavista, yahoo, etc.? If you are using the default Links, it works as is right out of the archive. I modified mine and it looks like this:

Quote:
<form action="<%db_cgi_url%>/search.cgi" method="GET">
<table cellpadding=10 align="center" valign="top" border=1 bgcolor="#D5E8E8">
<tr><td align="center" valign="top">
<b>Search again?</b><br>
<input type="text" size=30 name="query" value="<%query%>"> 
<input type=submit value="Search!"><br>
<small>
<a href="<%db_cgi_url%>/search.cgi">Advanced Search</a>
</small>
<hr width="50%">
<!-- Other Search Engines Begins -->
<b>Or Try Your Search For<br>
"<font color="#FF0000"><%query%></font>"<br>
Using One of These Search Engines:</b><br>
<small>
<a href="http://www.altavista.digital.com/cgi-bin/query?pg=q&what=web&q=<%term%>" target="jumpto">Altavista</a>
| <a target="jumpto" href=http://www.amazon.com/exec/obidos/external-search?mode=books&keyword=<%term%>&tag=bobsgoodstufflis">Amazon.com</a>
| <a target="jumpto" href="http://www.dejanews.com/dnquery.xp?QRY=<%term%>">Deja News</a>
| <a href="http://www.excite.com/search.gw?search=<%term%>" target="jumpto">Excite</a>
| <a href="http://www.hotbot.com/?SW=web&SM=SC&RG=NA&_v=2&DC=10&DE=2&MT=<%term%>" target="jumpto">Hotbot</a>
| <a href="http://www.infoseek.com/Titles?col=WW&sv=IS&lk=noframes&nh=10&qt=<%term%>" target="jumpto">Infoseek</a>
| <a href="http://www.looksmart.com/r_search?key=<%term%>" target="jumpto">Looksmart</a>
| <a href="http://www.lycos.com/cgi-bin/pursuit?cat=lycos&maxhits=20&query=<%term%>" target="jumpto">Lycos</a>
| <a href="http://search.go2net.com/crawler?general=<%term%>&method=0&target=&region=0&rpp=20&timeout=5&hpe=10" target="jumpto">MetaCrawler</a>
| <a href="http://search.yahoo.com/search?o=1&d=y&za=default&p=<%term%>" target="jumpto">Yahoo</a>
</small>
<!-- Other Search Engines Ends -->
</td></tr></table>
</td></tr></table>
</form>

That is from my template file, search_results.html. For non-templates, it would go in site_html.pl, sub site_html_search_results and would look like this:

Quote:
<form action="$db_cgi_url/search.cgi" method="GET">
<table cellpadding=10 align="center" valign="top" border=1 bgcolor="#D5E8E8">
<tr><td align="center" valign="top">
<b>Search again?</b><br>
<input type="text" size=30 name="query" value="$in{'query'}"> 
<input type=submit value="Search!"><br>
<small>
<a href="$db_cgi_url/search.cgi">Advanced Search</a>
</small>
<hr width="50%">
<!-- Other Search Engines Begins -->
<b>Or Try Your Search For<br>
"<font color="#FF0000">$in{'query'}</font>"<br>
Using One of These Search Engines:</b><br>
<small>
<a href="http://www.altavista.digital.com/cgi-bin/query?pg=q&what=web&q=$term" target="jumpto">Altavista</a>
| <a target="jumpto" href=http://www.amazon.com/exec/obidos/external-search?mode=books&keyword=$term&tag=bobsgoodstufflis">Amazon.com</a>
| <a target="jumpto" href="http://www.dejanews.com/dnquery.xp?QRY=$term">Deja News</a>
| <a href="http://www.excite.com/search.gw?search=$term" target="jumpto">Excite</a>
| <a href="http://www.hotbot.com/?SW=web&SM=SC&RG=NA&_v=2&DC=10&DE=2&MT=$term" target="jumpto">Hotbot</a>
| <a href="http://www.infoseek.com/Titles?col=WW&sv=IS&lk=noframes&nh=10&qt=$term" target="jumpto">Infoseek</a>
| <a href="http://www.looksmart.com/r_search?key=$term" target="jumpto">Looksmart</a>
| <a href="http://www.lycos.com/cgi-bin/pursuit?cat=lycos&maxhits=20&query=$term" target="jumpto">Lycos</a>
| <a href="http://search.go2net.com/crawler?general=$term&method=0&target=&region=0&rpp=20&timeout=5&hpe=10" target="jumpto">MetaCrawler</a>
| <a href="http://search.yahoo.com/search?o=1&d=y&za=default&p=$term" target="jumpto">Yahoo</a>
</small>
<!-- Other Search Engines Ends -->
</td></tr></table>
</td></tr></table>
</form>

I hope this helps.

[This message has been edited by Bobsie (edited June 02, 1999).]
Quote Reply
Re: $term $query and search yahoo and others In reply to
Hello Bobsie,
thank you for your reply.
I changed everything as you advised, but it didnt work: "Unknown tag: query"
So I changed the following like:

-------


<form action="<%db_cgi_url%>/search.cgi" method="GET">
<table cellpadding=10 align="center" valign="top" border=1 bgcolor="#D5E8E8">
<tr><td align="center" valign="top">
<b>Search again?</b><br>
<input type="text" size=30 name="query" value="<%term%>">
### changed <%query%> into <%term%>
<input type=submit value="Search!"><br>
-------------------
Now it works!!!
Thank you!
Now I will try to "repair" the error mentioned before - hope to get it fixed
Sincerely
Claus
Quote Reply
Re: $term $query and search yahoo and others In reply to
Hello
itīs me again
It did not work!
Either do I get "Unknown Tag: query" or "Unknown Tag: term"
What did I do: I changed (since I want to have the simple search onevery page) everything to <input type="text" size=30 maxlength="30" name="query" value="<%query%>">
Whether I replace the <%query%> with <%term%> or not I get one of the errors above.
Is there something missing, in site_html_templates.pl perhaps?
I donīt know.
Please help me again!
Thank you
Claus
Quote Reply
Re: $term $query and search yahoo and others In reply to
Hello Bobsie
itīs me again again.I tried something:
In site_html_templates I added
query => $query,
to %globals, then I added query => $query, to all subs, additionally to sub site_html_search_form + sub site_html_search_failure + sub site_html_search_results I added term => $term,
Ok, in search.html I left the value="<%query%>" as in all the other htmlīs and in search_results.html + search_error I changed it to value="<%term%>".
Now I can start a search from every page, and have the searchterm provided in the input field in _results.html and _error.html and in all the yahoos and exites and so on (works also with advanced search).
I think I dug it, I will test it now again, but a few minutes ago it did work, even after a rebuild of the site, I swear.
Phew! I hope it lasts.
If you have any comment on what I tried, please tell me! I will learn.
Thank you
Claus
Quote Reply
Re: $term $query and search yahoo and others In reply to
The <%query%> used in the template comes from the %in variable. In the script, it would be $in{'query'}, not $query. The %in variable is passed to the template in the load template instructions so <%query%> should work.

The difference between $term (<%term%> ) and $in{'query'} (<%query%> ) is that the term would add a hexadecimal number for a space (dog%20and%20cat) where as the query would not (dog and cat).

I hope this helps.
Quote Reply
Re: $term $query and search yahoo and others In reply to
Goog evening!
I tried to follow your advice, Bobsie, but since Iīm no programmer I didnt figure out how to do. Either the searchterm isnīt passed or I have the %20. If I cannot solve it (I think itīs just a matter of optic?) I will provide an explanation for the user.
If you have any suggestion or how-to I will appreciate it nevertheless.
Thank you
Claus
Quote Reply
Re: $term $query and search yahoo and others In reply to
Make sure your sub site_html_search_results looks like this:

Code:
sub site_html_search_results {
# --------------------------------------------------------
# This routine displays the search results.
#
my $term = &urlencode ($in{'query'});
&html_print_headers;
print &load_template ('search_results.html', {
term => $term,
link_results => $link_results,
category_results => $category_results,
next => $next,
cat_hits => $cat_hits,
link_hits => $link_hits,
%in,
%globals
});
}

If it does, then you should not get any errors when using <%term%> or <%query%> in the search_results.html template file.
Quote Reply
Re: $term $query and search yahoo and others In reply to
good morning, bobsie!
I did as you suggested and compared the part of code with what I had, commented out my #query => $in{'query'},

and commented out in %globals my attempt to be a programmer #query => $query, and #term => $term,

now it is (just one minute ago it did!) exactly what you told it should be.
I will either get me a beginners perl book or ask more before I act or better yet, both.
I thank you verrry much, Bobsie!
Claus

btw: you are a really very responsive and helpful person