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.
Jul 11, 1999, 11:34 AM
Veteran / Moderator (8669 posts)
Jul 11, 1999, 11:34 AM
Post #2 of 6
Views: 2244
In db.cgi, replace sub build_html_record with the following:
# --------------------------------------------------------
# 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
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
Jul 11, 1999, 1:37 PM
New User (4 posts)
Jul 11, 1999, 1:37 PM
Post #3 of 6
Views: 2249
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
I don't think I edited incorrectly but who knows? Any suggestions?
------------------
Fortress Web Design
www.fortressdesign.com
Jul 11, 1999, 3:00 PM
New User (4 posts)
Jul 11, 1999, 3:00 PM
Post #4 of 6
Views: 2251
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
http://www.fortressdesign.com/cgi-bin/dbman/db.cgi?db=nrba
guest/guest to login
------------------
Fortress Web Design
www.fortressdesign.com
Jul 11, 1999, 4:24 PM
Veteran / Moderator (8669 posts)
Jul 11, 1999, 4:24 PM
Post #5 of 6
Views: 2250
Sorry 'bout that. That's what I get for trying to type when I've got a headache.
Let's try this again:
# --------------------------------------------------------
# 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
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