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

Products: Gossamer Links: Development, Plugins and Globals: Re: [afinlr] Random Global Questions: Edit Log

Here is the list of edits for this post
Re: [afinlr] Random Global Questions
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

Edit Log: