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

Global for additional tables

Quote Reply
Global for additional tables
Hi,

when i use this <%Name%> i get directly the value of the Name in Table "Users" where Username is the logged in user!

Which global i need, if i use additional tables and want to ask the value?
e.g.:
Table Users-Profile: Username | Age | Birthday | ...

And i need the value "Age" from the logged in User!

What should i do?

Thanks in advance!

Coyu
Quote Reply
Re: [Coyu] Global for additional tables In reply to
Actually, the variables are available in the $USER hash, which is the Field=>value pair just like the links table.

They *should* be passed into the templates by default. Have you tried using <%Age%> and see if it works?

If you need to use the value in a global, (ie: perl code), it should be available as $USER->{'Age'}


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Global for additional tables In reply to
Hi,

i get an error "Unknown Tag" when i am using a field, that is not in Users!

What i need exact for a global, when i wish use the following syntax:

<%global_name('table_name','field_name')%>
e.g.:
<%global_name('Users_Profile','Age')%>

Thanks in advance!

Coyu
Quote Reply
Re: [Coyu] Global for additional tables In reply to
Hi,

if you want to use another table as far as I know you have to create a new .def file for your table and then you can create a global like:

Code:

my $results;
my $sth = $db->select ( { Name => "query" }, ['value']);
my $list = $sth->fetchall_hashref;
foreach my $value (@$list) {
$results .= "$valu\n";
}
return $results;


Regards

Niko
Quote Reply
Re: [el noe] Global for additional tables In reply to
Not sure if that actually answers what Coyu is asking for (I was talking to him via emails). If it is, then you would need to define $db too ;)

Code:
my $db = new GT::SQL '/path/to/defs/';

... or just use $DB, which already holds the LinksSQL GT::SQL object Wink

What I think Coyu is trying to do, is be able to pass ANY kind of query in via a tag... i.e;

Code:
<%GT::SQL::Condition->new('Field','>','5','another_field','LIKE','%foo%')%>

AFAIK, this isn't possible.

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] Global for additional tables In reply to
Hi Andy,

it should be possible to some extent by passing variables to a routine like:

Code:

<%routine($table,$col,$value,$condition)%>


what do you think?

Regards

n || i k o

Last edited by:

el noe: Mar 11, 2004, 5:22 AM
Quote Reply
Re: [el noe] Global for additional tables In reply to
Sure its possible... but it would be a huge global Wink Not something I would have the patience to write :p

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] Global for additional tables In reply to
And I think it makes no sense unless you access a lot of different tables with different qeries. Otherwise it would be easy to use something like the above... only neater Smile

Regards

Niko