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

List of Contributors - Global

Quote Reply
List of Contributors - Global
Hi,

I am using Pagebuilder to auto-generate a list of contributors (in case anyone is interested :-)

I added a field to Users called Contributors (Enum > Yes/No) and anither field called 'bio'

The used the following global:
fetch_editors

Code:
sub {
my $tags = shift;
local $_ = $tags;

lib->import('/path/to/admin');
my $table = GT::SQL->new('/path/to/admin/defs')->table('Users');
$table->select_options ('ORDER BY Name ASC', 'LIMIT 100');
my $sth = $table->select ( { Contributor => 'Yes'} );

my @output;
while (my $link = $sth->fetchrow_hashref) {
push (@output, $link);
}
return { top5_loop => \@output };
}

Then insert the following in the template where you want the info:

Code:
<%fetch_editor%>
<%loop top5_loop%>
<b><%Name%></b><br>
<%bio%>
<hr>
<br>
<%endloop%>

Cheers
Klaus

http://www.ameinfo.com
Quote Reply
Re: [klauslovgreen] List of Contributors - Global In reply to
If this is a Links SQL internal thing, then you can change the global to
Code:
sub {
my $table = $DB->table('Users');
$table->select_options ('ORDER BY Name ASC', 'LIMIT 100');
return { top5_loop => $table->select ( { Contributor => 'Yes'} )->fetchall_hashref };
}
The lib->import line is only needed in conjunction with Community, i.e. if you want to make use of the Community modules and tables (or the other way around, if you want to use Links specific modules/tables in Community). Also, you don't need to define a new GT::SQL object, since $DB already is such an object.

I just thought I let you know for your future globals Wink.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] List of Contributors - Global In reply to
Thanks Ivan... the simpler the better - appreciate your input..

Klaus

http://www.ameinfo.com