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

global to read any value from any category ?

Quote Reply
global to read any value from any category ?
Hi all,

I have searched all around in the forum (load/ read value/field...) but I can't find Unimpressed

How would a global be that would accept two parameters :
  • the ID of any category
  • the name of any field of the category


--> and return the value of that field in this category.

Please help Smile as my perl knowledge *only* tells me that it would probably need twice "shift" & then read the DB ... how ???

As this would be a very general function & commun problem, it could be in the ressource for LSQL (?)

thanks

Fabrice
Quote Reply
Re: [fff] global to read any value from any category ? In reply to
Try this;

Code:
sub {

my $ID = $_[0];
my $Field = $_[1];

my $table = $DB->table('Category');
my $sth = $table->select( { ID => $ID } );
my $val;
while (my $hit = $sth->fetchrow_hashref) {
$val = $hit->{$Field};
}

return $val;

}

Call with;

<%global_name($ID,'FieldName')%>

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!