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

Random Links Specified Per Category (continued ... )

Quote Reply
Random Links Specified Per Category (continued ... )
I am starting a new thread, because I still need some help with this, and I hope a new thread will help keep things clearer. (The other thread just confused me). Original Thread:
http://www.gossamer-threads.com/...orum_view_collapsed;

So, here goes:
I'd like to have 3 or so "random" links in each category be displayed. I will have seperate template sets for each category. Alex gave me some code to use that was supposed to limit the categories that the call pulls from, but I haven't gotten it to be successful.

I'd also like to be able to have "links" rotating on the home page, from specified categories.

1) a way to call (from seperate category pages) 3 links from that particular category and display them on the category page.

2) a way to call from the home page (or any other page) 3 random links from defined categories.

Random_Link global Alex gave me to try:

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

and then to call the random link, place this code on the category page for that particluar category.:

Code:
<%set Random_Category = 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%>

The problem is, that it still pulls from other categories.

Pweeze help me define this Crazy

Last edited by:

Evoir: Dec 26, 2001, 2:13 PM
Subject Author Views Date
Thread Random Links Specified Per Category (continued ... ) Evoir 10455 Dec 26, 2001, 1:15 PM
Thread Re: [Evoir] Random Links Specified Per Category (continued ... )
Paul 10314 Dec 26, 2001, 1:20 PM
Thread Re: [RedRum] Random Links Specified Per Category (continued ... )
Evoir 10251 Dec 26, 2001, 1:23 PM
Thread Re: [Evoir] Random Links Specified Per Category (continued ... )
Paul 10368 Dec 26, 2001, 2:00 PM
Post Re: [RedRum] Random Links Specified Per Category (continued ... )
Evoir 10304 Dec 26, 2001, 2:07 PM
Thread Re: [RedRum] Random Links Specified Per Category (continued ... )
Evoir 10329 Dec 26, 2001, 2:36 PM
Thread Re: [Evoir] Random Links Specified Per Category (continued ... )
DogTags 10413 Dec 27, 2001, 4:59 AM
Post Re: [DogTags] Random Links Specified Per Category (continued ... )
Paul 10302 Dec 27, 2001, 5:20 AM
Thread Re: [DogTags] Random Links Specified Per Category (continued ... )
Alex 10399 Dec 27, 2001, 9:48 AM
Post Re: [Alex] Random Links Specified Per Category (continued ... )
DogTags 10224 Dec 28, 2001, 4:52 AM
Thread Re: [Alex] Random Links Specified Per Category (continued ... )
Evoir 10309 Dec 28, 2001, 12:41 PM
Thread Re: [Evoir] Random Links Specified Per Category (continued ... )
pugdog 10293 Dec 29, 2001, 8:00 AM
Thread Re: [pugdog] Random Links Specified Per Category (continued ... )
Evoir 10289 Dec 29, 2001, 12:49 PM
Thread Re: [Evoir] Random Links Specified Per Category (continued ... )
pugdog 10207 Dec 29, 2001, 2:05 PM
Thread Re: [pugdog] Random Links Specified Per Category (continued ... )
Evoir 10262 Dec 29, 2001, 2:12 PM
Thread Re: [Evoir] Random Links Specified Per Category (continued ... )
pugdog 10224 Dec 29, 2001, 2:16 PM
Post Re: [pugdog] Random Links Specified Per Category (continued ... )
Evoir 10262 Dec 29, 2001, 2:29 PM
Thread Re: [Evoir] Random Links Specified Per Category (continued ... )
Alex 10220 Dec 29, 2001, 2:28 PM
Thread Re: [Alex] Random Links Specified Per Category (continued ... )
Evoir 10230 Dec 29, 2001, 2:43 PM
Thread Re: [Evoir] Random Links Specified Per Category (continued ... )
Alex 10171 Dec 29, 2001, 2:50 PM
Thread Re: [Alex] Random Links Specified Per Category (continued ... )
Evoir 10224 Dec 29, 2001, 3:04 PM
Thread Re: [Evoir] Random Links Specified Per Category (continued ... )
Alex 10235 Dec 29, 2001, 3:23 PM
Post Re: [Alex] Random Links Specified Per Category (continued ... )
Evoir 10117 Dec 29, 2001, 3:36 PM
Post Re: [Alex] Random Links Specified Per Category (continued ... )
DogTags 10222 Dec 29, 2001, 5:17 AM