Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Search.cgi Challenge!

Quote Reply
Search.cgi Challenge!
Who's up for a challenge! Theres no prize, but you do get my respect Smile

Jerry, Alex and Pugdog helped me out on a thread below regarding using that custom=1&thiscannowequal=*

The problem is that I can't log searches when doing that. I would like to be able to see what sorta system people are mainly after so that I can get reviews/advertising suiting the largest market.

I have tried some changes to search.cgi to do this, I did manage to make the script stop working, but not to log the searches Frown

Since there are a fiar few search terms, printing the results in the admin area that is somewhat easy to read would be good, or a seperate pages, listing the most common or something like that.

Thanks alot.

------------------
Michael Bray
....
Review your webhost, or find a new one at http://www.webhostarea.com


Quote Reply
Re: Search.cgi Challenge! In reply to
You've lost me...

LinkSQL automatically logs the search terms.

If you want to log the terms yourself, all you need to do is make a call to:

&log_query ($in->param('query'), 0);

Just pass it the term you want logged in the place of the $in->param('query')

If you want to do it purely yourself, look up my old thread on keyword logging, and just use the database call directly. I didn't do anything fancy (like count occurances) but you could copy the 'fancy' stuff from the &log_query routine.

I think I actually originally used the format for the hits update from jump.cgi to make my revised keyword logger, then it came built in, so I quit <G>



Quote Reply
Re: Search.cgi Challenge! In reply to
it's cause the query is always blank..

so it can't log searches..

hmm.. what do you want to log??

like

Space=<50mb

??

jerry
Quote Reply
Re: Search.cgi Challenge! In reply to
Yeah, but on the searches I do, they are nearly all just ranges.

So

Price=$30-$50 etc
Quote Reply
Re: Search.cgi Challenge! In reply to
well.. first you'd have to build it all up.. so before it gets logged.. you can sorta do a

Code:
if ($in->param('custom')) {
foreach (keys %in) {
#next if this is not a field;
$in->param('query') .= "$_=$in{$_} ";
#build up seperated by space
}
}

understand?
Quote Reply
Re: Search.cgi Challenge! In reply to
Thanks for the advice!

I didn't think about going about it like that, I'll get it to work from that, I'll probably do it flat file though Smile
Quote Reply
Re: Search.cgi Challenge! In reply to
I don't think you can do that, you'll want to us a separate variable (probably shouldn't overwrite $in->param('query') anyways. Something like:

my $search_critera;
foreach (qw!search fields!) {
$search_criteria .= $in{_};
}
&log_query ($search_criteria, $link_hits);

and it's done.

Cheers,

Alex
Quote Reply
Re: Search.cgi Challenge! In reply to
OK then I am meant to put that anywhere special in search.cgi or just anywhere it fits Smile

I don't won't to bugger it up, cause my site is finished, and I don't like stuffing up the database while someone is trying to use it.
Quote Reply
Re: Search.cgi Challenge! In reply to
Back Up Smile

Can someone tell me where to place the code... Thanks!
Quote Reply
Re: Search.cgi Challenge! In reply to
replace
Code:
&log_query ($in->param('query'), $link_count + $cat_count);

with
Code:
if ($in->param('custom')) {
my $criteria;
foreach (qw!search fields!) {
$criteria .= "$_=$in{$_} ";
}
chop $criteria;
&log_query ($criteria, $link_count);
}
else {
&log_query ($in->param('query'), $link_count + $cat_count);
}

and then you'd need to put all your links database fields in that bolded array

alex..

does links sql have something like @db_cols in links 2.0? i thought it would.. but i can't think of it this very moment..

------------------
Jerry Su
Links SQL Licensed
------------------



[This message has been edited by widgetz (edited January 22, 2000).]
Quote Reply
Re: Search.cgi Challenge! In reply to
Jerry,

Quote:
and then you'd need to put all your links database fields in that bolded array

What does that mean. I replaced the code, and in the search results now I get this...

Quote:
search= fields=

for the term searched. I think it has something to do with what you said, but I have no idea what a bolded array is.



------------------
Michael Bray
....
Review your webhost, or find a new one at http://www.webhostarea.com


Quote Reply
Re: Search.cgi Challenge! In reply to
oops.. mistake..

Code:
$criteria .= "$_=$in{$_} ";

to

Code:
$criteria .= "$_=$in{$_} " if ($in{$_});

also.. the search fields are like.. uh ... your custom fields.. for example..

space host location

or whatever..

------------------
Jerry Su
Links SQL User
------------------
Quote Reply
Re: Search.cgi Challenge! In reply to
OK then, so I am looking at this code now....

Code:
# Log the search results.
if ($in->param('custom')) {
my $criteria;
foreach (qw!search fields!) {
$criteria .= "$_=$in{$_} " if ($in{$_});
}
chop $criteria;
&log_query ($criteria, $link_count);
}
else {
&log_query ($in->param('query'), $link_count + $cat_count);
}

# If we want to bold the search terms...
if ($LINKS{search_bold}) {
my $tempquery = $query;
$tempquery =~ s/[+\-"']//g;
my @terms = split /\s/, $tempquery;
foreach (@terms) {
if (s/(.+)\*(.*)/$1/) {
push @terms, $2 if ($2);
$link_results =~ s,(<[^>]+> )|(\Q$_\E),defined($1) ? $1 : "<B>$2</B>",gie;
$category_results =~ s,(<[^>]+> )|(\Q$_\E),defined($1) ? $1 : "<B>$2</B>",gie;
}
else {
$link_results =~ s,(<[^>]+> )|(\Q$_\E),defined($1) ? $1 : "<B>$2</B>",gie;
$category_results =~ s,(<[^>]+> )|(\Q$_\E),defined($1) ? $1 : "<B>$2</B>",gie;
}
}
}

I am meant to manuelly type in the fields somewhere, and if so, where? Thanks!
Quote Reply
Re: Search.cgi Challenge! In reply to
try here foreach (qw!search fields!) {

------------------
LookHard Search
lookhard.hypermart.net
Lavon Russell
Quote Reply
Re: Search.cgi Challenge! In reply to
michael??

don't you know perl!? Smile

like bmxer said..

Code:
foreach (qw!search fields!) {

just say you let your users have custom searches in things like isNew, isPopular, and isChanged

basically.. you do this

Code:
foreach (qw!isNew isPopular isChanged!) {

it should log things like

isNew=Yes
isNew=No
etc..

------------------
Jerry Su
Links SQL User
------------------