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

Template global that pulls data from another table

Quote Reply
Template global that pulls data from another table
Maybe someone can help me with this... I have been beating my head against the wall for about 45 minutes and can't find the answer to this on the forum or in the help. I know you can do it, I just don't know how.

I am trying to add a function to the "Template Globals" that will be referenced from the detailed page with:
<%venue_title%>

I need the sub to return the "title" field from another table named "Venues". My problem is that I can't seem to reference any of the data in the Links table (specifically a field named "venueid" that I added ... or even ID for that matter) from within my sub. What am I missing? Here is what I have:
<PRE>
sub {
my %rec = @_;
my $ven_db = $DB->table('Venues');
my $sth = $obj->select({ ID => $rec{'VenueID'} });

if(my $row = $sth->fetchrow_hashref) {
return $row{'Title'};
}

return "Invalid Venue!";
}
</PRE>
From what I see in the docs, @_ (sub params) is set to a hashset of all the fields of the record that was opened for the current page. Is this not the case?

Thanks!
-Shaun

Subject Author Views Date
Thread Template global that pulls data from another table scooley 2095 Jun 25, 2001, 9:19 PM
Post Re: Template global that pulls data from another table
Stealth 2039 Jun 26, 2001, 6:00 AM
Thread Re: Template global that pulls data from another table
pugdog 2023 Jun 26, 2001, 6:31 AM
Post Re: Template global that pulls data from another table
scooley 2031 Jun 26, 2001, 2:16 PM