Gossamer Forum
Home : Products : Links 2.0 : Customization :

Re: [Technel] Please Help Me With This MOD

Quote Reply
Re: [Technel] Please Help Me With This MOD In reply to
Another thread dug up from the dusty past... Unimpressed

When you have a problem like this, go through your code (either on screen or printed), and put a letter by each curly bracket, and make sure they match open- and close-wise, and maybe put notes in for the closing ones. Ignore the smaller ones, like "$rec{$field}", since it's obvious that both brackets are there.

Example:

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

$output = "<p><table border=1 width=450>\n";
foreach $field (@db_cols) { #B
next if ($db_form_len{$field} == -1);
# >>> Admin URL View mod
if ($field eq "URL" && $rec{$field} ne "") { #C
$output .= qq~
<tr><td align=right valign=top width=20%><$font>$field:</font></td>
<td width=80%><$font><a href="$rec{$field}" target="_blank">$rec{$field}</a></font></td></tr>~;
} #/C
else { #D

$output .= qq~
<tr><td align=right valign=top width=20%><$font>$field:</font></td>
<td width=80%><$font>$rec{$field}</font></td></tr>
~;
} #/D
# >>> Original code:
# $output .= qq~
# <tr><td align=right valign=top width=20%><$font>$field:</font></td>
# <td width=80%><$font>$rec{$field}</font></td></tr>
# ~;
# <<< Admin URL View mod
} #/B ends 'foreach'
$output .= "</table></p>\n";
return $output;
} #/A



Here are the subs with the code added for this mod, you can just paste these in if you have not made any other changes to your files:
Code:
sub build_html_record {
# --------------------------------------------------------
# Builds a record based on the config information.
#
my (%rec) = @_;
my ($output, $field);

$output = "<p><table border=1 width=450>\n";
foreach $field (@db_cols) {
next if ($db_form_len{$field} == -1);
# >>> Admin URL View mod
if ($field eq "URL" && $rec{$field} ne "") {
$output .= qq~
<tr><td align=right valign=top width=20%><$font>$field:</font></td>
<td width=80%><$font><a href="$rec{$field}" target="_blank">$rec{$field}</a></font></td></tr>~;
}
else {
$output .= qq~
<tr><td align=right valign=top width=20%><$font>$field:</font></td>
<td width=80%><$font>$rec{$field}</font></td></tr>
~;
}
# >>> Original code:
# $output .= qq~
# <tr><td align=right valign=top width=20%><$font>$field:</font></td>
# <td width=80%><$font>$rec{$field}</font></td></tr>
# ~;
# <<< Admin URL View mod
}
$output .= "</table></p>\n";
return $output;
}sub build_html_record_form {
# --------------------------------------------------------
# Builds a record form based on the config information.
#
my ($output, $field, $multiple, $name);
($_[0] eq "multiple") and ($multiple = 1) and shift;
my (%rec) = @_; $output = "<p><table border=1>";# Go through a little hoops to only load category list when absolutely neccessary.
if ($in{'db'} eq 'links') {
exists $db_select_fields{$db_cols[$db_category]}
or ($db_select_fields{$db_cols[$db_category]} = join (",", &category_list));
}
else {
$db_select_fields{'Related'} or
($db_select_fields{'Related'} = $db_select_fields{'Mult-Related'} = join ",", &category_list);
} foreach $field (@db_cols) {
# Set the field name to field-key if we are doing multiple forms.
$multiple ? ($name = "$field-$rec{$db_key}") : ($name = $field);
if ($db_select_fields{"Mult-$field"}) { $output .= "<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%>" . &build_select_field($field, $rec{$field}, $name, "MULTIPLE SIZE=3") . "</td></tr>\n"; }
elsif ($db_select_fields{$field}) { $output .= "<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%>" . &build_select_field($field, $rec{$field}, $name) . "</td></tr>\n"; }
elsif ($db_radio_fields{$field}) { $output .= "<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%>" . &build_radio_field($field, $rec{$field}, $name) . "</td></tr>\n"; }
elsif ($db_checkbox_fields{$field}) { $output .= "<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%>" . &build_checkbox_field ($field, $rec{$field}, $name) . "</td></tr>\n"; }
elsif ($db_form_len{$field} =~
/(\d+)x(\d+)/) { $output .= qq~<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%><textarea wrap="virtual" name="$name" cols="$1" rows="$2">$rec{$field}</textarea></td></tr>\n~; }
elsif ($db_form_len{$field} == -1) { $output = qq~<input type=hidden name="$field" value="$rec{$field}">\n$output~; }
# >>> Admin URL View mod
else {
if ($field eq "URL" && $rec{$field} ne "") { $output .= qq~<tr><td align=right valign=top width=20%><$font><a href="$rec{$field}" target="_blank">$field</a>:</font></td><td width=80%><input type=text name="$name" value="$rec{$field}" size="$db_form_len{$field}" maxlength="$db_lengths{$field}"></td></tr>\n~; }
else { $output .= qq~<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%><input type=text name="$name" value="$rec{$field}" size="$db_form_len{$field}" maxlength="$db_lengths{$field}"></td></tr>\n~; }
}
# >>> Original code:
# else { $output .= qq~<tr><td align=right valign=top width=20%><$font>$field:</font></td><td width=80%><input type=text name="$name" value="$rec{$field}" size="$db_form_len{$field}" maxlength="$db_lengths{$field}"></td></tr>\n~; }
# <<< Admin URL View mod
} # ends 'foreach'
$output .= "</table></p>\n";
return $output;
}


Leonard
aka PerlFlunkie
Subject Author Views Date
Thread New admin URL-view mod Owen 10677 Apr 8, 2000, 2:56 PM
Thread Re: New admin URL-view mod
jcrow 10579 Apr 8, 2000, 6:34 PM
Thread Please Help Me With This MOD
Technel 6637 Sep 16, 2006, 6:29 PM
Post Re: [Technel] Please Help Me With This MOD
PerlFlunkie 6643 Sep 17, 2006, 2:36 PM
Post Re: New admin URL-view mod
Owen 10565 Apr 8, 2000, 7:25 PM
Post Re: New admin URL-view mod
jcrow 10568 Apr 8, 2000, 7:37 PM
Post Re: New admin URL-view mod
Owen 10579 Apr 10, 2000, 12:30 PM
Post Re: New admin URL-view mod
Ugur 10553 Apr 10, 2000, 10:41 PM
Post Re: New admin URL-view mod
dprophit 9967 Jul 31, 2000, 4:12 PM
Post Re: New admin URL-view mod
sdyson 9625 Sep 10, 2000, 11:25 AM
Post Re: New admin URL-view mod
Technel 8463 Mar 21, 2001, 3:29 AM
Thread Re: [Owen] New admin URL-view mod
jbridge14 7818 Nov 27, 2001, 5:54 PM
Post Re: [jbridge14] New admin URL-view mod
Thomas. 7773 Nov 28, 2001, 3:18 AM
Post Re: [Owen] New admin URL-view mod
Vs_Greg 7737 Nov 30, 2001, 1:58 AM