Gossamer Forum
Home : Products : Links 2.0 : Customization :

show record in admin panel in two columns

Quote Reply
show record in admin panel in two columns
well, once you add more than just a few fields to the database, you end up doing a lot of scrolling up down. I got tired of that and took a page out of site_html_templates.pl and modified build_html_record_form in db_utils.pl

make the following changes in red
Code:
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) = @_;
my ($half) = 39;
# Note: adjust the number 39 as needed to get an even distribution of the fields
# It may not be the half-way point

my ($i) = 0;
$output = "<TABLE BORDER=0><TR><TD VALIGN=TOP>";

$output .= "<p><table border=1>";
# Note: don't forget to add the period after $output in the previous line
# 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));
# alt categories mod
($db_select_fields{$db_cols[$db_alt]} =
$db_select_fields{'Mult-AltCategories'} = 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);
# alt categories mod

# We check to see if we are half way through, if so we stop this table cell
# and begin a new one (this lets us have category names in two columns).
if ($i == $half) {
$output .= "</TABLE><TD><TABLE BORDER=1><TR><TD VALIGN=TOP>\n";
}
$i++;


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=5") . "</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~; }

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~; }
}
$output .= "</TD></TR></table></TD></TR></TABLE></p>\n";
return $output;
}

Just a couple of things. You may need to modify the %db_def section of linkd.def. Otherwise, instead of scrolling up and down, you will end up scrolling left and right. Adjust the field width as shown below. Changing this will not change HTML pages if you are using templates.

Description => [5, 'alpha', '35x10', 1200, 1, '', ''],

I haven't taken the time to identify the other sub routines but they could adjusted as above.


Gene
"The older I get, the more I admire competence, just simple competence in any field from adultery to zoology."