Gossamer Forum
Home : Products : DBMan : Installation :

Clickable links in Auto-Generate??

Quote Reply
Clickable links in Auto-Generate??
I have the database set up and it seems to work fine using the auto-generate forms option. My question is... can you create a "clickable" link if one of the fields auto generated is a URL? Right now the URL comes out as plain text when the record is displayed.
Quote Reply
Re: Clickable links in Auto-Generate?? In reply to
In db.cgi, replace sub build_html_record with the following:

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

$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) && (!$per_admin));
$rec{$field} =~ s/\n/<BR>/g; # Keeps formatting in textarea fields
$output .= qq~<tr><td align=right valign=top width=20%><$font>$field:</font></td>~;
if ($rec{$field} =~ /^http:/) { # Creates clickable URLs
$url = $rec{$field};
$url =~ s/<\/?B>//g;
print qq~<td width=80%><a href="$url"><$font>$rec{$field}</font></a></td></tr>~;
}
elsif ($rec{$field} =~ /.+\@.+\..+/) { # Creates clickable email addresses
$url = $rec{$field};
$url =~ s/<\/?B>//g;
print qq~<td width=80%><a href="mailto:$url"><$font>$rec{$field}</font></a></td></tr>~;
}
else {
print qq~<td width=80%><$font>$rec{$field}</font></td></tr>~;
}
}
$output .= "</table></p>\n";
return $output;
}

Be very careful when you replace the subroutine, that you are replacing the correct one -- make sure the names match exactly -- and that you only replace one subroutine.

If you get an error after you add this, you will know that you made a mistake.

Be sure to keep your old db.cgi file until you know that you have installed this correctly.

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





Quote Reply
Re: Clickable links in Auto-Generate?? In reply to
Well there's good news and bad news. The edited code did produce clickable links for the URLs and the e-mail addresses but it skewed all of the table fields to the right and moved all of the table data to the first line above the actual display table. The result is a continuous string of data on the first line and all of the table fields aligned to the right of the screen with no data in them.

I don't think I edited incorrectly but who knows? Any suggestions?

------------------
Fortress Web Design
www.fortressdesign.com
Quote Reply
Re: Clickable links in Auto-Generate?? In reply to
I just triple checked the code and it looks the same. If you'd like to see what the display is looking like, you can access the DB at:

http://www.fortressdesign.com/cgi-bin/dbman/db.cgi?db=nrba

guest/guest to login

------------------
Fortress Web Design
www.fortressdesign.com
Quote Reply
Re: Clickable links in Auto-Generate?? In reply to
Sorry 'bout that. That's what I get for trying to type when I've got a headache. Smile

Let's try this again:

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

$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) && (!$per_admin));
$rec{$field} =~ s/\n/<BR>/g; # Keeps formatting in textarea fields
$output .= qq~<tr><td align=right valign=top width=20%><$font>$field:</font></td>~;
if ($rec{$field} =~ /^http:/) { # Creates clickable URLs
$url = $rec{$field};
$url =~ s/<\/?B>//g;
$output .= qq~<td width=80%><a href="$url"><$font>$rec{$field}</font></a></td></tr>~;
}
elsif ($rec{$field} =~ /.+\@.+\..+/) { # Creates clickable email addresses
$url = $rec{$field};
$url =~ s/<\/?B>//g;
$output .= qq~<td width=80%><a href="mailto:$url"><$font>$rec{$field}</font></a></td></tr>~;
}
else {
$output .= qq~<td width=80%><$font>$rec{$field}</font></td></tr>~;
}
}
$output .= "</table></p>\n";
return $output;
}

Again, apologies.


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





Quote Reply
Re: Clickable links in Auto-Generate?? In reply to
Much Better!! Thank you for the prompt and efficient response. It's working fine now.