Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Re: [JonathanKincaid] Detailed pages and image upload questions

Quote Reply
Re: [JonathanKincaid] Detailed pages and image upload questions In reply to
Hi,

Try this =)

<%global_name($ID,'FieldName','Table')%> (last part is optional)

Code:
sub {
# -------------------------------------------------------------------
# Call with <%global_name($ID,'FieldName')%>
# NOTE: This is for the CATEGORY images...

my ($ID,$field,$table) = @_;

$table ||= 'Links';

# make sure a fieldname and ID are provided...
if (!$ID || !$field) { return "You need to define the ID and fieldname."; }

# get the actual path to where the file is/will be saved...
my $schema = $DB->table($table)->cols;
my $path = $schema->{$field}->{'file_save_url'};
$path =~ s,/$,,; # get rid of trailing / at end of $path

my $image_details = $DB->table($table."_Files")->select( { ForeignColName => $field, ForeignColKey => $ID } )->fetchrow_hashref;

my $id = $image_details->{ID};
my $filename = $image_details->{File_Name};
my $file_url = $image_details->{File_URL}; # this is only the URL/folder

my @cut = split //, $id;
my $folderid = $cut[$#cut];

my $url = "$file_url/$folderid/$id-$filename";


$url =~ s|([^\/]+)$|GT::CGI->escape( $1 )|e;

return $url;

}

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!
Subject Author Views Date
Thread Detailed pages and image upload questions Chris1 6193 Sep 13, 2001, 4:23 PM
Post Re: [Chris1] Detailed pages and image upload questions
Chris1 6032 Sep 13, 2001, 4:35 PM
Thread Re: [Chris1] Detailed pages and image upload questions
Alex 5978 Sep 13, 2001, 5:57 PM
Thread Re: [Alex] Detailed pages and image upload questions
Chris1 5978 Sep 14, 2001, 7:19 AM
Thread Re: [Chris1] Detailed pages and image upload questions
Alex 6021 Sep 14, 2001, 8:50 AM
Post Re: [Alex] Detailed pages and image upload questions
Chris1 5952 Sep 14, 2001, 9:13 AM
Post Re: [Alex] Detailed pages and image upload questions
Evoir 5893 Sep 22, 2001, 10:29 AM
Thread Re: [Alex] Detailed pages and image upload questions
Spawn 5961 Sep 21, 2001, 4:29 AM
Thread Re: [Spawn] Detailed pages and image upload questions
Alex 5905 Sep 22, 2001, 1:08 PM
Thread Re: [Alex] Detailed pages and image upload questions
JonathanKincaid 5544 Sep 4, 2005, 2:33 PM
Post Re: [JonathanKincaid] Detailed pages and image upload questions
Andy 5496 Sep 5, 2005, 2:41 PM