Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Random Featured Link

Quote Reply
Random Featured Link
I have been using some code I found in the Plugins forum for a random link display on my home page:

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;
}


What I wanted to do is make the global check that the link is not only Validated ('isValidated' => 'Yes') but is Featured as well ('isFeatured' => 'Yes'). I tried:

sub {
my $db = $DB->table('Links');
my $total = $db->count ( 'isValidated' => 'Yes', 'isFeatured' => '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;
}

but it didn't seem to work.

Also, for some reason when I use this it will only display the full link.html and won't let me loop to use just some of the link options.

Any ideas? TIA!

--

Kriis
Subject Author Views Date
Thread Random Featured Link kriis 5521 Aug 15, 2002, 8:38 PM
Thread Re: [kriis] Random Featured Link
Andy 5429 Aug 15, 2002, 11:52 PM
Thread Re: [Andy] Random Featured Link
kriis 5429 Aug 16, 2002, 1:20 AM
Thread Re: [kriis] Random Featured Link
Andy 5416 Aug 16, 2002, 8:17 AM
Thread Re: [Andy] Random Featured Link
Payooo 5391 Aug 16, 2002, 8:55 AM
Thread Re: [Payooo] Random Featured Link
Andy 5378 Aug 16, 2002, 9:52 AM
Thread Re: [Andy] Random Featured Link
kriis 5395 Aug 16, 2002, 10:20 AM
Thread Re: [kriis] Random Featured Link
Andy 5246 Dec 9, 2003, 8:22 AM
Thread Re: [Andy] Random Featured Link
SalB 5051 Mar 4, 2006, 11:48 AM
Thread Re: [SalB] Random Featured Link
tandat 5054 Mar 4, 2006, 7:08 PM
Thread Re: [tandat] Random Featured Link
SalB 5024 Mar 5, 2006, 3:14 AM
Post Re: [SalB] Random Featured Link
tandat 5018 Mar 7, 2006, 1:09 AM