Home : Products : DBMan SQL : Discussion :

Products: DBMan SQL: Discussion: Re: [604] Anybody Home?????: Edit Log

Here is the list of edits for this post
Re: [604] Anybody Home?????
Thanks, it's working!

I'm now trying to use this code in another area of my website, that pulls photos from another table. I have it set up to the point where it's pulling the photo name (whatever.jpg) from the file column of another table, using this global:

sub {
my $tags = GT::Template->tags;
my $id = $tags->{ID};
my ($table, $field) = @_;
my $sth = $DB->table($table)->select({ $field => $id});
my $tab = $DB->table($table);
$tab->select_options('ORDER BY Date DESC', 'LIMIT 25');
my $sth = $tab->select({ $field => $id});
my @output;
while (my $rs = $sth->fetchrow_hashref ) {
push @output, $rs;
return { loop_hash => \@output };

What I would like help with, if you can, is changing the above global so that it returns the file path name (such as example: "2/2-filename.jpg") included instead of just the bare filename.jpg

I have the following global which does this perfectly when the file is in the same table:

sub {
my $tags = GT::Template->tags;
my $id = $tags->{TankID};
my ($table, $image_col) = @_;
my $file = $DB->table($table)->file_info($image_col, $id) or return "ID $id does not have a file attached.";
return $file->File_RelativePath();

So again, if you know how to essentially combine these two globals so that the first global returns file path name instead of just the file name, I would really appreciate the help. I have tried so many different combinations of the code to get it to work but haven't had any success. I always just get the "ID $id does not have a file attached." Any ideas?

Also, this will unfortunately only be useful if I can use the loop command on my template to show the file path of all search results. Am I going to be able to do this since it's calculated in a global?

Last edited by:

Dempsey: Sep 19, 2009, 10:46 AM

Edit Log: