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
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!