Gossamer Forum
Quote Reply
top5 global
I used the following global and then inserted the following on my index.html page
<%top5%>
<%loop top5_loop%>
<%Title%>: <%Hits%>
<%endloop%>

but nothing is showing up.. I am not sure what I have missed here so if anyone can point me in the right direction I would appreciate it. What I would really like is to list the top 5 rated sites on my home page not top hits but i can live with top hits if a rated global is not available.

----------------------------------------------------------------
This global will display the links in your database which have accumulated the most hits in descending order. It could be titled "top5".
sub {
my $tags = shift;
my $table = $DB->table('Links');
$table->select_options ('ORDER BY Hits DESC', 'LIMIT 5');
my $sth = $table->select;
my @output;
while (my $link = $sth->fetchrow_hashref) {
push (@output, $link);
}
return { top5_loop => \@output };
}
You can change the 'LIMIT' number to designate the number of links you want to be displayed. Insert the following loop in the desired template:
<%top5%>
<%loop top5_loop%>
<%Title%>: <%Hits%>
<%endloop%>
Added: Tue Dec 17 2002
Quote Reply
Re: [knewt] top5 global In reply to
The code looks like it should work.

Try turning on debugging and running the code again, something may show up.
Quote Reply
Re: [Paul] top5 global In reply to
thanks Paul
figured it out. I was trying to display it on my home page, not the home page generated by linksSQL just my main index.html . I read in another post that you can't have globals on html pages that are not generated by linksSQL. I will have to figure that out first with ssi's or something.
Quote Reply
Re: [knewt] top5 global In reply to
Hi,

You might want to have a look at the PageBuilder plugin - that might do the trick for you.

Klaus

http://www.ameinfo.com