Gossamer Forum
Quote Reply
Widgetz
Hello,

This is for Jerry, as if you didn't know already. Smile

Can you convert your category and search sort mod for Links SQL. If so I am going to make my site around that, and when you convert it I will add it in. If not, well then I won't create my site so that you can sort by field names.

Thanks.

------------------
James L. Murray
VirtueTech, Inc.
www.virtuetech.com


Quote Reply
Re: Widgetz In reply to
with SQL that is ten times easier..

it's just FIELD (ASC or DESC)

in the query..

jerry
Quote Reply
Re: Widgetz In reply to
Forgive me...but what query. I don;t fully understand how it works.

<-- PERL Blind. Smile

------------------
James L. Murray
VirtueTech, Inc.
www.virtuetech.com


Quote Reply
Re: Widgetz In reply to
What exactly are you trying to do?

I know I've posted a few ways to make changes to the output, and you can change the sort order for the main items in the Links.pm file.

What Jerry is saying, is to change the way a search/query works -- all you need to do is add an "ORDER BY <fieldname> ASC|DESC" to the routine to make it work the way you want.

ASC stands for ascending, and DESC stands for descending. To arrange a query by Add_Date in newest-first order, you'd want to ORDER BY Add_Date DESC

You'd put that into the SELECT statement where the links are obtained. Then, unless the list is further processed (as it is on the COOL and NEW pages) that is the order the links will display in.

If you list exactly what you want to do, it's a lot easier to give an answer Smile

Things are so much easier with the SQL engine, that most things are only a parameter or statement added to the query, rather than a full-fledged mod.



------------------
POSTCARDS.COM -- Everything Postcards on the Internet www.postcards.com
LinkSQL FAQ: www.postcards.com/FAQ/LinkSQL/







Quote Reply
Re: Widgetz In reply to
I just want to be able to do the same as CNET does when you choose to sort by,lets say, the price field or the shipping field.

Jerry did this in Links 2.0. I didn't get that mod to work though.

------------------
James L. Murray
VirtueTech, Inc.
www.virtuetech.com


Quote Reply
Re: Widgetz In reply to
Again, I'm not sure what you mean, but making a guess anyway, you would need to edit your search forms to include a passed parameter that is set inside search.cgi --

such as OrderField and DispOrder.

A series of check boxes could let the user pick the field they want to order by, then either ASCending or DESCending.

You'd pass that into search.cgi as any other parameter, and tag it on the end of the query so that you'd end up with something like

ORDER BY $in->param('OrderField') $in->param('DispOrder')

added to the query statement.

Looking at the search.cgi -- it's using db->query to do the work. That is looking for certain parameters:

Code:
($opt_r->{'so'} eq 'ASC') ? ($so = 'ASC') : ($so = 'DESC');
($opt_r->{'sb'}) and ($sb = "ORDER BY " . ${$opt_r}{'sb'} . " $so");

Using that, :

In your forms make what I called DispOrder "so" (sort order) and what I called OrderField "sb" (sort-by), then in search.cgi, where you see the call:

Code:
$link_hits = $linkdb->query ( { query => $query, mh => $mh, nh => $nh, filter => \%filter, ww => $ww } );

add:

so => $in->param('so'), sb => $in->param('sb'),

to the hash, after the ww (whole word) parameter, and you will have effectively overidden the defaults.

Untested, but it should work.

------------------
POSTCARDS.COM -- Everything Postcards on the Internet www.postcards.com
LinkSQL FAQ: www.postcards.com/FAQ/LinkSQL/









[This message has been edited by pugdog (edited December 21, 1999).]
Quote Reply
Re: Widgetz In reply to
Which unfortunately won't work. =) Right now, if you search using the search index, the only way you can get your results returned is by best match first. We may look at adding sorting later, but it's not a trivial thing.

Cheers,

Alex
Quote Reply
Re: Widgetz In reply to
Why is it so complex? It would seem that it would be easier to do it that way, than any other way, since it's not trying to figure out a 'best fit' score. It's just pulling the subset of links, and ordering them.

Couldn't you then have another subroutine that would be called if the other parameters are set, rather than the sort_by_score ??

Or, another CGI program like the previous search.cgi that would be called for the non-general searches? There is no reason why there only has to be one all-purpose routine to do all the searching. The database can be accessed so many different ways, why impose limitations?

Also, as for the score... I still don't quite understand why you can sort on it, but can't report it Smile

It seems that a lot of functioning has been removed from the search routines,