Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Re: [RedRum] Random Links Specified Per Category (continued ... )

Quote Reply
Re: [RedRum] Random Links Specified Per Category (continued ... ) In reply to
OKOK... so I'm a little slow.

what needs to happen is
<%set Random_CatID = 9%>

NOT

<%set Random_Category = 9%>

I feel like that was some sort of test or something... Wink Oh well. I'm glad to have figured it out, finally. This is a really nice Global. Thanks Alex and RedRum.

final Global:

Code:
sub {
my $tags = shift;
my $link_db = $DB->table('Links','CatLinks');
my $cat_id = $tags->{Random_CatID};
my $limit = $tags->{Random_Limit} || 3;
my (@output, $sth);
$link_db->select_options ('ORDER BY RAND()', "LIMIT $limit");
if ($cat_id) {
$sth = $link_db->select ( { CategoryID => $cat_id });
}
else {
$sth = $link_db->select;
}
while (my $hash = $sth->fetchrow_hashref) {
push @output, $hash;
}
return { Random_Loop => \@output }
}

Final html code for category template:
Code:
<%set Random_CatID = 9%>
<%Random_Link%>
<%loop Random_Loop%>
<p><%body_font%><A href="<%db_cgi_url%>/detail_page.cgi?ID=<%ID%>"><b><%Title%></b><br></A> <%Description%>
[<A href="<%db_cgi_url%>/detail_page.cgi?ID=<%ID%>">more</A>]</%body_font%>
<br>
<%endloop%>

Subject Author Views Date
Thread Random Links Specified Per Category (continued ... ) Evoir 10695 Dec 26, 2001, 1:15 PM
Thread Re: [Evoir] Random Links Specified Per Category (continued ... )
Paul 10551 Dec 26, 2001, 1:20 PM
Thread Re: [RedRum] Random Links Specified Per Category (continued ... )
Evoir 10488 Dec 26, 2001, 1:23 PM
Thread Re: [Evoir] Random Links Specified Per Category (continued ... )
Paul 10606 Dec 26, 2001, 2:00 PM
Post Re: [RedRum] Random Links Specified Per Category (continued ... )
Evoir 10541 Dec 26, 2001, 2:07 PM
Thread Re: [RedRum] Random Links Specified Per Category (continued ... )
Evoir 10567 Dec 26, 2001, 2:36 PM
Thread Re: [Evoir] Random Links Specified Per Category (continued ... )
DogTags 10650 Dec 27, 2001, 4:59 AM
Post Re: [DogTags] Random Links Specified Per Category (continued ... )
Paul 10540 Dec 27, 2001, 5:20 AM
Thread Re: [DogTags] Random Links Specified Per Category (continued ... )
Alex 10637 Dec 27, 2001, 9:48 AM
Post Re: [Alex] Random Links Specified Per Category (continued ... )
DogTags 10461 Dec 28, 2001, 4:52 AM
Thread Re: [Alex] Random Links Specified Per Category (continued ... )
Evoir 10546 Dec 28, 2001, 12:41 PM
Thread Re: [Evoir] Random Links Specified Per Category (continued ... )
pugdog 10530 Dec 29, 2001, 8:00 AM
Thread Re: [pugdog] Random Links Specified Per Category (continued ... )
Evoir 10526 Dec 29, 2001, 12:49 PM
Thread Re: [Evoir] Random Links Specified Per Category (continued ... )
pugdog 10445 Dec 29, 2001, 2:05 PM
Thread Re: [pugdog] Random Links Specified Per Category (continued ... )
Evoir 10499 Dec 29, 2001, 2:12 PM
Thread Re: [Evoir] Random Links Specified Per Category (continued ... )
pugdog 10461 Dec 29, 2001, 2:16 PM
Post Re: [pugdog] Random Links Specified Per Category (continued ... )
Evoir 10500 Dec 29, 2001, 2:29 PM
Thread Re: [Evoir] Random Links Specified Per Category (continued ... )
Alex 10458 Dec 29, 2001, 2:28 PM
Thread Re: [Alex] Random Links Specified Per Category (continued ... )
Evoir 10469 Dec 29, 2001, 2:43 PM
Thread Re: [Evoir] Random Links Specified Per Category (continued ... )
Alex 10408 Dec 29, 2001, 2:50 PM
Thread Re: [Alex] Random Links Specified Per Category (continued ... )
Evoir 10462 Dec 29, 2001, 3:04 PM
Thread Re: [Evoir] Random Links Specified Per Category (continued ... )
Alex 10472 Dec 29, 2001, 3:23 PM
Post Re: [Alex] Random Links Specified Per Category (continued ... )
Evoir 10354 Dec 29, 2001, 3:36 PM
Post Re: [Alex] Random Links Specified Per Category (continued ... )
DogTags 10459 Dec 29, 2001, 5:17 AM