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

global: Adding A Random Link

Quote Reply
global: Adding A Random Link
Hi,

I tested the global one:

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


being the page:

http://www.gossamer-threads.com/...s/Detailed/1834.html

I have the version of Mysql: 3.23.46

But this one does not work, i have the folowing error:

A fatal error has occured:

GT::Config (10988): Unable to compile 'random_link' in file '/home/domain/cgi-bin/admin/templates/default/globals.txt': syntax error at (eval 14) line 15, at EOF
syntax error at (eval 14) line 16, near "}
}"
at /home/domain/cgi-bin/admin/GT/Template.pm line 461.

Please enable debugging in setup for more details.

Thank's
Quote Reply
Re: [michelb] global: Adding A Random Link In reply to
Remove the ; from:

return { Random_Loop => \@output; }


...it shouldn't be there :)

Last edited by:

Paul: Apr 4, 2002, 1:23 AM
Quote Reply
Re: [Paul] global: Adding A Random Link In reply to
Thank's

I have just tested and he work correctly has share that this.

I would like is to display a link via a specific category and he doesn't not function with the tag:

<%Random_Link%>
<%loop Random_Loop%>
<%set Random_Category = 353%>
Random: <%Title%>: <%URL%><BR>
<%endloop%>

Quote Reply
Re: [michelb] global: Adding A Random Link In reply to
Ok,

I'm not sure what you are trying to do, or what you are hoping to do, but using "set Random_Category" AFTER the Random_Loop is returned, wouldn't do anything.

You might want to pass the category parameter into the Random_Link routine:

<%Random_Link ('353')%>

It would then be the first parameter in the subroutine.

You could also pass in <%Random_Link ($Category_ID)%> or whatever variable is holding the category ID (can be Category_ID, Cat_ID, cat_id, ID, etc depending on the template )


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] global: Adding A Random Link In reply to
Hi,

I would like that the global display a link being in a specific category, in the Home Page.

Thank's