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

top 5 of a category

(Page 2 of 2)
> >
Quote Reply
Re: top 5 of a category In reply to
This was a post to the wrong topic, but maybe I have an idea.

If you know the category ID, for example, when you are building a category page, or when you are in subcategory.html (such as when building the print_cat routine for the home page).

Anyway....


I really don't have time for this, and I've spent too much on it already.... (too many other things I really have to do) But... give this a try for a starting point:


Code:
Add this to the list after the big select statement:

$get_top5_links = $LINKDB->prepare (" SELECT * FROM Links WHERE CategoryID = ? ORDER BY Hits LIMIT 5 ");


Then, before where you added the $link_count variable, you want to calculate the top_5

my $top_links_count=0;
for my $i (0 .. 4) {
$tmp = $LINKDB->array_to_hash (${$get_top5_links_r}[$i]);
$tmp->{'links_count'}= ++$top_links_count;
$OUT{TOP5} .= &site_html_link ($tmp);
}

The "logic" (staying with the flow of Links SQL) is to create another output variable that contains the 5 top links as the values, rather than all the links, or categories, or whatever.

Examine those routines for what they are doing, and make the changes as needed to the starting code above.



[This message has been edited by pugdog (edited April 14, 2000).]
Quote Reply
Re: top 5 of a category In reply to
Hi all; im looking just for another thing:
I want to have the last X new entrees with title, description and link to the detail-page.

Better to give some code here (or parts of it :-)
it would be to show how to do:

1. Make a query
2. Give the found links out

I think this must be in build.cgi.

Robert

> >