Gossamer Forum
Home : Products : Gossamer Links : Discussions :

display username 'league table'

Quote Reply
display username 'league table'
Hi,

is it possible to display a user 'league table' with hpyerlinked usernames (linking to a page listing links submitted by?) and number of links submitted?

username1 (12)
username2 (10)
username3 (8)

If so, can it be done easily?

Or would this be a 'custom job'

Thanks
Colin Thompson
Quote Reply
Re: [colintho] display username 'league table' In reply to
Shouldn't be very hard to do at all. What are all your requirements?

Philip
------------------
Limecat is not pleased.
Quote Reply
Re: [fuzzy logic] display username 'league table' In reply to
Hi

the idea would be to have a page display this 'league table' of users with number of links submitted

This page showing the users, with their corresponding number of links submitted, in descending order

Each username with a hyperlink to a page listing their submitted links

Like this page, which shows the 'search results' for links submitted by username skinnyboo

http://www.skinnyboo.com/cgi-bin/search.cgi?LinkOwner=skinny_boo
Colin Thompson

Last edited by:

colintho: Jul 27, 2006, 10:58 PM
Quote Reply
Re: [colintho] display username 'league table' In reply to
I found the answers from within this forum, after various search terms and putting the 'pieces' together.

This is a summary of what I found:

added global: top_submitter

using this code from Andy Newby ( UltraNerds )

sub {

my $back;
my @links;

my $min_links = $_[0] || 2;

my $Links = $DB->table('Links');

$Links->select_options('GROUP BY LinkOwner', "HAVING link_cnt > $min_links", 'ORDER BY link_cnt DESC','LIMIT 10');

my $cond = new GT::SQL::Condition;
$cond->add('LinkOwner','!=','admin');

my $sth = $Links->select(
['LinkOwner',
'COUNT(LinkOwner) AS link_cnt'], $cond) || return $GT::SQL::error;

while (my ($user) = $sth->fetchrow_array) {

my $link = $DB->table('Users')->get( { Username => $user } );

$link->{LinkCount} = $DB->table('Links')->count( { LinkOwner => $user } );

push @links, $link;

}

return { Top_Submitter_Loop => \@links };

}

-------------------

A new template page added to the 'luna' templates folder, topusers.html

-------------------

Combined with this, againf from Andy Newby ( UltraNerds ) which I modified to add the hyperlink, which is added to the new templete page topusers.html

<%top_submitter('1')%>

<%loop Top_Submitter_Loop%>
<a href="http://www.yoursite.com/cgi-bin/search.cgi?LinkOwner=<%Username%>"><%Username%></a> (<%LinkCount%>) <br/>
<%endloop%>

-------------------

This is called up using the page.cgi function

Like this:

http://www.skinnyboo.com/.../page.cgi?p=topusers


I hope this helps anybody else looking for something similar to display top users

NOTE: number of users displayed can be edited on one of the lines in the global

'ORDER BY link_cnt DESC','LIMIT 10'); (this will display top 10)

'ORDER BY link_cnt DESC','LIMIT 20'); (this will display top 20)


Many thanks to the 'techies' and forum contributors.
Colin Thompson