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

Show detailed links within a category

Quote Reply
Show detailed links within a category
I'm trying to show links within a category that have a detailed page via search.cgi.

I'm thinking in something like this:
/search.cgi?CategoryID=<category_id>&isDetail=1&query=something

What should I put in the "query" ? I tried with a "*" or "ALL" and I get the following (for category 9):

Search (14874): Fatal: query: Can't execute: SELECT count(*) FROM Links WHERE ID in () and (( CategoryID = "9")) (You have an error in your SQL syntax near ') and (( CategoryID = "9"))' at line 1) at admin/Links/DBSQL.pm line 1492

Any guidance?
Quote Reply
Re: Show detailed links within a category In reply to
 


Probably the best thing to do is add a couple of hidden fields
to your search query when you call search.cgi to do a category
search called "hasDetails" along with the CategoryID field.

Set hasDetails to 1 for yes, and 0 for no. A user can set that by a
radio button, or you can have it default.

Then, at the top of the search.cgi add another test to set the parameter:

($in->param('hasDetails')) ? ($detailed = " CategoryID='$in->param('CategoryID')' AND isDetail=1 ") : ($detailed = '');

You need to pass hasDetails=>$detailed after ww to the search query routine.

Then,

in sub query in DBSQL.pm you need to add another line:

($opt_r->{'hasDetails'}) ? ($hasDetails = ($opt_r->{'hasDetails'}) : ($hasDetails = ' ');

This sets the value of the variable to add to the query.

Then, further down, there are two SQL statements, one line is "$where'

You need to change to to "$where $hasDetails"

That way, if there is a detailed page, the
" CategoryID=nn AND isDetailed=1 ' is added
to query string. If not, a ' ' is added to the string which is ignored.

This _should_ work. I haven't tested it, and you need to make sure you
declare "$detailed" in the search.cgi and $hasDetails in query sub.



In order to take advantage of the features of the "search query" routines,
you need to do a bit more work to trick the program. You could use the
$in->param('hasDetails') to branch to a hard coded "SELECT statement" but
you don't get the ranking by SCORE.

There may be problems with this, but it's a start.

I'm probably over-thinking it.