Gossamer Forum
Home : Products : DBMan : Customization :

Multiple Upload File mod , Image not displaying in results

Quote Reply
Multiple Upload File mod , Image not displaying in results
As the title says I cannot seem to get images to be displayed in my search results, but they are showing fine in modify/delete forms etc. I admit I have been editing some code to get the look I want mainly in the excerpts below.



sub html_record {
# --------------------------------------------------------
# How a record will be displayed. This is used primarily in
# returning search results and how it is formatted. The record to
# be displayed will be in the %rec hash.

my (%rec) = @_; # Load any defaults to put in the VALUE field.
($db_auto_generate and print &build_html_record(%rec) and return);

my $font_color = 'Font face="Verdana, Arial, Helvetica" Size=2 Color=#003399';
my $font = 'Font face="Verdana, Arial, Helvetica" Size=2';

$rec{'Address'} =~ s/\n/<BR>/g;
$url{'Email'} = $rec{'Email'};
$url{'Email'} =~ s/<\/?B>//g;
$url{'Website'} = $rec{'Website'};
$url{'Website'} =~ s/<\/?B>//g;

print qq|
<TABLE WIDTH="400" CELLPADDING=4 CELLSPACING=0 BORDER=0 BGCOLOR="#FFFFFF">|;
if ($per_admin) {
print qq|
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font_color>index:</FONT></TD>
<TD WIDTH="250">&nbsp;<$font>$rec{'index'}</Font></TD></TR>
|;
}
print qq|
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font_color>Company Name:</FONT></TD>
<TD WIDTH="250"><$font>$rec{'Company Name'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font_color>Country:</FONT></TD>
<TD WIDTH="250"><$font>$rec{'Country'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font_color>Contact:</FONT></TD>
<TD WIDTH="250"><$font>$rec{'Contact'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font_color>Address:</FONT></TD>
<TD WIDTH="250"><$font>$rec{'Address'}</Font></TD></TR>|;
if ($rec{'Telephone'}) {
print qq|
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font_color>Telephone:</FONT></TD>
<TD WIDTH="250"><$font>+ $rec{'Telephone'}</Font></TD></TR>
|;
}
print qq||;
if ($rec{'Fax'}) {
print qq|
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font_color>Fax:</FONT></TD>
<TD WIDTH="250"><$font>+ $rec{'Fax'}</Font></TD></TR>
|;
}
print qq||;
if ($rec{'Email'}) {
print qq|
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font_color>Email:</FONT></TD>
<TD WIDTH="250"><$font><a href="mailto:$url{'Email'}">$rec{'Email'}</a>
|;
}
print qq||;
if ($rec{'Website'}) {
print qq|
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150"><$font_color>Website:</FONT></TD>
<TD WIDTH="250"><$font><a href="$url{'Website'}">$rec{'Website'}</a>
|;
}
print qq||;
if ($rec{'GRAPHIC'}) {
print qq||;
if (-e "$SAVE_DIRECTORY/$rec{$db_key}") {
opendir (GRAPHIC, "$SAVE_DIRECTORY/$rec{$db_key}") or &cgierr("unable to open directory: $SAVE_DIRECTORY/$rec{$db_key}. Reason: $!");
@files = readdir(GRAPHIC);
closedir (GRAPHIC);
foreach $file (@files) {
next if ($file =~ /^\./); # Skip "." and ".." entries..
next if ($file =~ /^index/); # Skip index.htm type files..
print qq|<img src="$SAVE_DIRECTORY_URL/$rec{$db_key}/$file">|;
}
}
print qq|
</Font></TD></TR>
|;
}
print qq|
</TABLE>
|;
}

and here


sub html_view_success {
# --------------------------------------------------------
# This page displays the results of a successful search.
# You can use the following variables when displaying your
# results:
#
# $numhits - the number of hits in this batch of results.
# $maxhits - the max number of hits displayed.
# $db_total_hits - the total number of hits.
# $db_next_hits - html for displaying the next set of results.
#

my (@hits) = @_;
my ($numhits) = ($#hits+1) / ($#db_cols+1);
my ($maxhits); $in{'mh'} ? ($maxhits = $in{'mh'}) : ($maxhits = $db_max_hits);

&html_print_headers;
print qq|
<html>
<head>
<title>$html_title: Search Results.</title>
</head>

<body bgcolor="#ffffff">
<!-- <table border=1 bgcolor="#FFFFFF" cellpadding=5 cellspacing=3 width=500 valign=top>
<tr><td colspan=2 bgcolor="navy"><FONT FACE="MS Sans Serif, arial,helvetica" size=1 COLOR="#FFFFFF">
<b>$html_title: Search Results</b>
</font></td></tr>
</table>
<p><$font>
Your search returned <b>$db_total_hits</b> matches.</font> -->
|;
if ($db_next_hits) {
print "<br><$font>Pages: $db_next_hits</font>";
}

# Go through each hit and convert the array to hash and send to
# html_record for printing.
for (0 .. $numhits - 1) {
print "<P>";
&html_record (&array_to_hash($_, @hits));
}
if ($db_next_hits) {
print "<br><$font>Pages: $db_next_hits</font>";
}
print qq|
<p>
<table border=0 bgcolor="#ffffff" cellpadding=5 cellspacing=3 width=500 valign=top>
<tr><td></td></tr>
</table>
</body>
</html>
|;
}



I've obviously done something wrong, anyone see any immediate problems? I have posted another question in the discussions forum which is in someway related to this... I have been modifying the code to try and get single result pages that have no headers or footers just the data and the picture. I want each result page to act like a seperate webpage on my site, called from a dropdown menu system.

Last edited by:

Formant: Sep 12, 2002, 7:21 AM
Quote Reply
Re: [Formant] Multiple Upload File mod , Image not displaying in results In reply to
Did you name your field within the .cfg file:

Graphic => [11,'alpha',0,3,1,'','Yes'] ## changing to the correct field position number

%db_checkbox_fields = ( Graphic => 'Yes' );

This would be case sensitive. Using the field name in all caps may conflict with calls to other variables with the same name.


if ($rec{'GRAPHIC'}) {

change to:

if ($rec{'Graphic'} eq 'Yes') {

I would also change this portion so that you table cell will end even if there is no graphic

print qq|<img src="$SAVE_DIRECTORY_URL/$rec{$db_key}/$file">|;
}
}
}
print qq| </Font></TD></TR></TABLE> |;

You might also want to add in your html_record

# after my (%rec) = @_;

$rec{$db_key} =~ s/<.?B>//g;

Hope this helps

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] Multiple Upload File mod , Image not displaying in results In reply to
Well I ended up reinstalling the script last night before I saw this reply and everything seems to be working ok now. Probably just a typo or pasted over some content I shouldn't have :)

Thanks for the reply though,