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

Re: [afinlr] Random Global Questions

Quote Reply
Re: [afinlr] Random Global Questions In reply to
This global works great. Thanks afinlr. Smile

I have another small customization, not sure if it should be in the global, or on my subcategory.html template.

I'd like the global to NOT spit out any randoms on the page that shows links. Just in catgory and subcategory pages. Does this make sense?

Main categories=yes random link
subcategories=yes random link
links=no random link

Would this be something that I change in the template or the random global, and how would I do this?

Thanks again!

current global:
sub {
my $tags = shift;
my $link_db = $DB->table('Links','CatLinks');
my $cat_id = $tags->{Random_CatID};
my $limit = $tags->{Random_Limit} || 1;
my (@output, $sth);
$link_db->select_options ('ORDER BY RAND()', "LIMIT $limit");
my $condition = GT::SQL::Condition->new( 'Description', 'IS NOT', \'NULL','isValidated','=','Yes');
if ($cat_id) {
$sth = $link_db->select ($condition, { CategoryID => $cat_id });
}
else {
$sth = $link_db->select;
}
while (my $hash = $sth->fetchrow_hashref) {
push @output, $hash;
}
my $cat_db = $DB->table('Category');
my $sth2 = $cat_db->select ( ['ID'],{ FatherID => $cat_id });
while (my ($child_id) = $sth2->fetchrow_array){
my $sth3 = $link_db->select ($condition, { CategoryID => $child_id, isValidated => 'Yes' });
while (my $hash2 = $sth3->fetchrow_hashref) {
push @output, $hash2;

}
}
@output = sort {return (rand > 0.5) ? 1 : -1;} @output;
splice (@output,$limit);
return { Random_Loop => \@output }
}

Last edited by:

Evoir: Aug 7, 2002, 1:09 PM
Subject Author Views Date
Thread Random Global Questions Evoir 8111 Aug 2, 2002, 4:34 PM
Thread Re: [Evoir] Random Global Questions
afinlr 7972 Aug 2, 2002, 5:14 PM
Thread Re: [afinlr] Random Global Questions
Evoir 8049 Aug 3, 2002, 9:24 AM
Thread Re: [Evoir] Random Global Questions
afinlr 7993 Aug 3, 2002, 11:22 AM
Post Re: [afinlr] Random Global Questions
Evoir 7957 Aug 3, 2002, 11:49 AM
Thread Re: [afinlr] Random Global Questions
Paul 7969 Aug 3, 2002, 11:56 AM
Thread Re: [Paul] Random Global Questions
Evoir 7983 Aug 3, 2002, 12:02 PM
Thread Re: [Evoir] Random Global Questions
afinlr 7910 Aug 3, 2002, 12:52 PM
Thread Re: [afinlr] Random Global Questions
Evoir 7913 Aug 7, 2002, 1:08 PM
Post Re: [Evoir] Random Global Questions
Evoir 7851 Aug 8, 2002, 2:45 PM
Thread Re: [Paul] Random Global Questions
afinlr 7939 Aug 3, 2002, 12:18 PM
Thread Re: [afinlr] Random Global Questions
Paul 7991 Aug 3, 2002, 12:43 PM
Thread Re: [Paul] Random Global Questions
Evoir 7862 Sep 13, 2002, 11:41 AM
Thread Re: [Evoir] Random Global Questions
Alex 7902 Sep 13, 2002, 12:34 PM
Thread Re: [Alex] Random Global Questions
Evoir 7815 Sep 13, 2002, 12:49 PM
Thread Re: [Evoir] Random Global Questions
Alex 7840 Sep 13, 2002, 1:42 PM
Post Re: [Alex] Random Global Questions
afinlr 7779 Sep 13, 2002, 3:37 PM
Post Re: [Alex] Random Global Questions
Evoir 7786 Sep 13, 2002, 4:34 PM
Post Re: [Alex] Random Global Questions
Evoir 7775 Sep 13, 2002, 4:37 PM
Post Re: [Alex] Random Global Questions
Evoir 7822 Sep 13, 2002, 4:56 PM