Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Access other user data in Review_Loop?

Quote Reply
Access other user data in Review_Loop?
I have an ID column that I have added to my Users table. During the building of the reviews, I would like to access the User ID to construct a link to another part of the site for more detail on that user.

I'm wondering what the best way to do this is? I had in mind a quick global to query the User table with Username=Review_Owner and return the User ID?

Does anyone have any simple examples of globals that can query a Links table and return a unique value? I've been searching for a while and haven't found anything that I can modify within my Perl abilities Unsure.
Quote Reply
Re: [aus_dave] Access other user data in Review_Loop? In reply to
<%global($Field_to_use_for_looking_up)%>

Code:
sub {

my $in = $_[0];

my $user = $DB->table('Users')->select( ['Field_Name'], { Condition => $in } )->fetchrow;

}

Basically, you need to use ['FieldName'] (obviously replace with the field you want to use), and then the "fetchrow" part simply grabs a simple result.

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Access other user data in Review_Loop? In reply to
Andy, I get an error - "Can't call method "fetchrow" on an undefined value at (eval 39) line 4."

I have <%reviewer_id($Review_Owner)%> in my template, and a global called reviewer_id:

Code:
sub {
my $in = $_[0];
my $user = $DB->table('Users')->select( ['vbID'], { Condition => $in } )->fetchrow;
}

Any ideas on what I have wrong?
Quote Reply
Re: [aus_dave] Access other user data in Review_Loop? In reply to
Hi,

I didn't mean the Condition bit literally ;)

Try this;

Code:
sub {
my $user = $DB->table('Users')->select( ['vbID'], { Username => $_[0] } )->fetchrow;
return $user;
}

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Access other user data in Review_Loop? In reply to
I told you I was a Perl novice Crazy.

It works nicely now!
Quote Reply
Re: [aus_dave] Access other user data in Review_Loop? In reply to
Angelic