Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Random Link

Quote Reply
Random Link
What I woul like to do is put the Random Link on our home page and have it not take you to a Random Site but open 1 Random Link from our database, showing that links title description etc. How would I achive this?
American Home Inspector Directory
Quote Reply
Re: [lizardlips] Random Link In reply to
Hi,

There are aobut a million example of this =)

Code:
sub {
my $db = $DB->table('Links');
my $total = $db->count ( { 'isValidated' => 'Yes' } );
my $rand = int( rand($total) );

$db->select_options ("LIMIT $rand, 1");

my $link = $db->select->fetchrow_hashref;
my $html = Links::SiteHTML::display('link', $link);
return \$html;
}

..and call with;

<%global_name%>

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates