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... Oh well. I'm glad to have figured it out, finally. This is a really nice Global. Thanks Alex and RedRum.
final Global:
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:
<%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%>
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... 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%>