Gossamer Forum
Home : Products : DBMan : Customization :

Auto Formating + Linking of e-mail addresses & url's

Quote Reply
Auto Formating + Linking of e-mail addresses & url's
I am setting up a database for the music industry to use.

I tried out Web Teachers Webdata which has a great set up procedure but I could not customise it enough (the html layout) so I am switching over to DBMan.

I have one question:

What would be the code and where would I have to insert it so that the data in the e-mail field and the url's in each record are automatically turned into links so that users when viewing records can instantly go the the website or send an e-mail.

Please explain this in a step by step manner assuming that I am a complete beginner! Smile
Quote Reply
Re: Auto Formating + Linking of e-mail addresses & url's In reply to
You'll need to change a subroutine in the db.cgi script. Look for

sub build_html_record {

Delete that line and all the lines below it, up to (but not including) the beginning of the next subroutine, which is

sub build_html_record_form

Then, paste in the following code in the place were you deleted the lines:

Code:
sub build_html_record {
# --------------------------------------------------------
# Builds a record based on the config information.
#
my (%rec) = @_;
my ($output, $field);

$output = "<p><table border=0 width=450>";
foreach $field (@db_cols) {
next if ($db_form_len{$field} == -1);
next if (($db_form_len{$field} == -2) and (!($per_admin)));
$output .= qq~<tr><td align=right valign=top width=20%><$font>$field:</font></td>
<td width=80%>~;
if ($rec{$field} =~ /^http:/) {
$output .= qq~<a href="$rec{$field}"><$font>$rec{$field}</font></a>~;
}
elsif ($rec{$field} =~ /.+\@.+\..+/) {
$output .= qq~<a href="mailto:$rec{$field}"><$font>$rec{$field}</font></a>~;
}
else {
$output .= qq~<$font>$rec{$field}</font>~;
}
$output .= qq~</td></tr>~;
}
$output .= "</table></p>\n";
return $output;
}

I haven't tested this, except to be sure there aren't syntax errors, but I'm pretty sure it will work.


------------------
JPD







[This message has been edited by JPDeni (edited July 12, 1999).]
Quote Reply
Re: Auto Formating + Linking of e-mail addresses & url's In reply to
Hi, i did try using the modified version of build_html_record in order to get clickable urls and e-mail addresses.
It works (urls are indeed clickable), however there seems to be a problem.
The records get printed out of the table cell in which they are supposed to be.

Any help?

Petz
Quote Reply
Re: Auto Formating + Linking of e-mail addresses & url's In reply to
Try it now. I changed the code.


------------------
JPD