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

Sorting by Link field

Quote Reply
Sorting by Link field
Hello,

Please go to my site here http://www.medinfolinks.com/...ation/Consumer_Info/

I want to be able to allow the users to sort by link fields in real time as they see fit. If you go to the site you'll see what I want to do.

Any one have ideas on how to do this?

------------------
James L. Murray
PaintballCity.com
The Yahoo of Paintball
www.paintballcity.com
AIM: Paintball City
ICQ: 44147229





Quote Reply
Re: Sorting by Link field In reply to
Use page.cgi and insert the codes that Widgetz wrote for search.cgi/category.cgi scripts for LINKS 2.0. They would have to be hacked a bit to work with LINKS SQL, but this should get you started.

I believe the latter scripts are located at:

jsu7785.hypermart.net/search.txt

AND

jsu7785.hypermart.net/category.txt

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.


[This message has been edited by AnthroRules (edited April 13, 2000).]
Quote Reply
Re: Sorting by Link field In reply to
Hello Alex,

Thanks for your reply. I tried what you said and I keep getting software errors. Here is my sub generate_category_page:

[Snipped]

And here is the error I get when I run the perl debugger in Telnet:
Code:
syntax error at page.cgi line 204, near "| |"
[Thu Apr 13 02:28:26 2000] page.cgi: Global symbol "$subcategory_r" requires explicit package name at page.cgi line 206.
[Thu Apr 13 02:28:26 2000] page.cgi: Global symbol "%OUT" requires explicit package name at page.cgi line 206.
[Thu Apr 13 02:28:26 2000] page.cgi: Global symbol "$in" requires explicit package name at page.cgi line 206.
[Thu Apr 13 02:28:26 2000] page.cgi: Global symbol "$get_links" requires explicit package name at page.cgi line 207.
[Thu Apr 13 02:28:26 2000] page.cgi: Global symbol "%sb" requires explicit package name at page.cgi line 207.
[Thu Apr 13 02:28:26 2000] page.cgi: Global symbol "$category_r" requires explicit package name at page.cgi line 208.
[Thu Apr 13 02:28:26 2000] page.cgi: Global symbol "$links_r" requires explicit package name at page.cgi line 209.
[Thu Apr 13 02:28:26 2000] page.cgi: Global symbol "$get_alt" requires explicit package name at page.cgi line 212.
[Thu Apr 13 02:28:26 2000] page.cgi: Global symbol "$alt_r" requires explicit package name at page.cgi line 214.
[Thu Apr 13 02:28:26 2000] page.cgi: Global symbol "$numlinks" requires explicit package name at page.cgi line 218.
[Thu Apr 13 02:28:26 2000] page.cgi: Global symbol "$url" requires explicit package name at page.cgi line 220.
[Thu Apr 13 02:28:26 2000] page.cgi: Global symbol "$page_num" requires explicit package name at page.cgi line 220.
[Thu Apr 13 02:28:26 2000] page.cgi: Global symbol "$get_related" requires explicit package name at page.cgi line 235.
[Thu Apr 13 02:28:26 2000] page.cgi: Global symbol "$name" requires explicit package name at page.cgi line 238.
[Thu Apr 13 02:28:26 2000] page.cgi: Global symbol "$tmp" requires explicit package name at page.cgi line 260.
syntax error at page.cgi line 267, near "}"
Content-type: text/html

<H1>Software error:</H1>
<CODE>page.cgi has too many errors.
</CODE>

Any ideas?

------------------
James L. Murray
PaintballCity.com
The Yahoo of Paintball
www.paintballcity.com
AIM: Paintball City









[This message has been edited by Alex (edited April 13, 2000).]
Quote Reply
Re: Sorting by Link field In reply to
Yes, I hate UBB. =( Remove the space between the double pipes.

Cheers,

Alex
Quote Reply
Re: Sorting by Link field In reply to
Yeah I tried that....It still doesn't work.

Here is the error now:
Code:
[Thu Apr 13 02:50:13 2000] page.cgi: Global symbol "%sb" requires explicit package name at page.cgi line 206.
Content-type: text/html

<H1>Software error:</H1>
<CODE>Execution of page.cgi aborted due to compilation errors.
</CODE>

[This message has been edited by Ground Zero (edited April 13, 2000).]
Quote Reply
Re: Sorting by Link field In reply to
Actually, it would work as you are not doing a search, but rather a category listing. If you edit page.cgi in generate_category_page, you'll see:

$get_links = $LINKDB->prepare ("SELECT * FROM Links WHERE CategoryID = ? ORDER BY $LINKS{build_sort_order_category} LIMIT 1000 ");

You just need to replace $LINKS{build_sort_order_category} with something else. So for instance, if you pass in sb=Hits to page.cgi, then you could do:

my $sb = $in->param('sb') &#0124; &#0124; $LINKS{build_sort_order_category};

which says to use what you've been passed in, or the default. Then replace the above with ORDER BY $sb

and it should work.

Then it's just a matter of making the column links and adding sb=Title, sb=Hits, etc.

Hope this helps,

Alex
Quote Reply
Re: Sorting by Link field In reply to
Problem is, as reported before, the searches are returned in "score" order.

Alex has been working on a fix to this (upgrade?) and probably will be in the next release -- ie: a way to pass a working sort order to the sort routines.

But, the "logic" for what you want to do, is just link to each of the column titles, with the base URL and sort order hard-coded, and then append the "query" term when the page is output.

As I said, it probably won't work in the 1.11 release.

Quote Reply
Re: Sorting by Link field In reply to
Odds are you are missing a ',",,,or ; somewhere, since it usually will pick up missing (){}

Otherwise, you have tried to use field names as variables without defining them first to belong to the subroutine ie: with 'my'

Quote Reply
Re: Sorting by Link field In reply to
Ah... I guess I missed that subtlty.

The sort-by-category (links inside a category) works unless you have a lot of "alt" links mixed in. (previous bug).

Searches are returned by "score" and categories are returned by the "build_sort_order" variable -- with the execption of the "links" hash being merged with the "alt-links" hash in a pseudo-random way.

Because of the search box on the bottom of the page, I got the impression it was a "search"....

But, a caveat would be that you could show the links in any order the user would want on a category display, but you couldn't do that on "search" which means two different user interfaces, and the most _useful_ IMHO use of user-selectable-sorts is on a search, where a lot of random information comes up.

Anyway --- Alex ---- I hope you've been working on a fix to the 'score' order only and alt-links problems!!!

Quote Reply
Re: Sorting by Link field In reply to
Hello,

When I call to page.cgi how do I pass the Category I'm in to the script so that it displays the sort order I want from the cateogory I called it from?

------------------
James L. Murray
PaintballCity.com
The Yahoo of Paintball
www.paintballcity.com
AIM: Paintball City







Quote Reply
Re: Sorting by Link field In reply to
If I'm reading you right, the category you are in is stored in the Links.CategoryID as a number, or in the category record.

In page.cgi in the build_category_page routine:

Code:
# Set the category info for displaying purposes.
$OUT{category_id} = $category_r->{'ID'};
$OUT{category_name} = $category_r->{'Name'};

Should hold the information.

When outputting the page, just pass the ID into the strings in the templates.

Then, when you call the script from the page (this is search.cgi) you've passed in the parameter you want to pass to the search query.

Make sense?

Remember, all the scripts read the $in->param(xyz) fields, so you test for anything passed to the programs at any point.