Gossamer Forum
Home : Products : DBMan : Customization :

Changing field names

Quote Reply
Changing field names
I installed jpdeni's relational mod. After getting the updated code the default installation worked perfect. I had a rough time when I tried to write my own field names, so I just used her names and edited the html to display what I wanted. That works great until an error happens and a user is asked to fix field price and I am using it as a gender field.

On a db that was working, I took my item.cfg and replaced the word Price with Gender in the two areas it was found. In the db def and the select field build up area I made the switch. I took item_html and made the switch in the html record form, html record, and html record long. I searched user_html, but did not find a cross reference. When I used the new script the first record is correct, but the records there after are missing my renamed field.

I edited html record to show a detailed output for each record. It worked fine till I changed Price to Gender. I did not alter the db at all. I had been using the db with just different field names but the same data. Below is a copy of the lines I edited:
In Reply To:
In Record form it was
<TD VALIGN="TOP" WIDTH="475"> |; print &build_select_field("Price",$rec{'Price'}); print qq|</TD></TR>
I changed it to this
<TD VALIGN="TOP" WIDTH="475"> |; print &build_select_field("Gender",$rec{'Gender'}); print qq|</TD></TR>
I changed this
<TD WIDTH="80%"> <$font>$rec{'Price'}</Font></TD></TR>
To this in html record and html record long
<TD WIDTH="80%"> <$font>$rec{'Gender'}</Font></TD></TR>
Here is a copy of my entire html_record that I changed to show a full record instead of the short long version.
In Reply To:
sub html_record {
# --------------------------------------------------------
# How a record will be displayed. This is used primarily in
# returning search results and how it is formatted. The record to
# be displayed will be in the %rec hash.
# This is the "short display" -- the list of records that are returned
# from a search.

my (%rec) = @_; # Load any defaults to put in the VALUE field.
$rec{'UserID'} =~ s/<\/?B>//g;
&switch_to_user;
%rec2 = &get_record($rec{'UserID'});
&switch_to_item;
($db_auto_generate and print &build_html_record(%rec) and return);

# create link to full display
$record_number = ((($nh - 1) * $db_max_hits) + $i);

$long_url = $ENV{'QUERY_STRING'};
$long_url =~ s/\&nh=\d+//;
$long_url =~ s/\&mh=\d+//;

$long_url = "$db_script_url?$long_url&nh=$record_number&mh=1";

print "<TD>"; # do not remove this! It is necessary to make the records display properly

# Below is where you define what you want to appear for each record in the "short" display.
# You can make this whatever you want, and display as many fields as you would like.
# Choose which of the fields you would like for users to click on to reach the full display
# of records and use that field name in place of "Title" below.
#
# Be sure that you use <a href="$long_url"> for the link to your full record display.

# <-- Start of short display formatting -- >

$rec{'Description'} =~ s/\n/<BR>/g;
print qq|
<TABLE WIDTH="450" CELLPADDING=0 CELLSPACING=0 BORDER=1 bordercolor="#FFa500" bgcolor="#dfdfdf">
<TR><TD>Kept by:</TD>
<TD><a href="mailto:$rec2{'UserEmail'}">$rec2{'UserFirstName'} $rec{'UserLastName'}</a></TD></TR>
<TR><TD>From:</TD>
<TD>$rec2{'UserCity'} $rec2{'UserState'} $rec2{'UserCountry'}</TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>Boa: Name/Species:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'Item'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>Python: Name/Species:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'Classification'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>Gender:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'Gender'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>Description:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'Description'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>DateAdded:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'DateAdded'}</Font></TD></TR>
<tr><td colspan=2 align=center><a href="$db_script_link_url&UserID=$rec{'UserID'}&view_records=1">See all items by this user</a></td></tr>
</TABLE>

|;


# Add or remove columns as needed. Be sure you add the $long_url link to one of your fields

# <-- End of short display formatting -- >

print "</TD>"; # do not remove this! It is necessary to make the records display properly

}
I am not sure what I may have missed. The original db worked fine. With just one field rename I botched the output when more than one record is being printed. I have 2 versions of dbman installed. This version is with the renamed field.http://www.tinygiants.com/...bman2/db.cgi?db=user
This is my stock field name version. http://www.tinygiants.com/...dbman/db.cgi?db=user

Thanks for the help.
Dale

Quote Reply
Re: Changing field names In reply to
Hi Dale, in the sub switch_to_user (I think that is the actual name) each of the field names are listed. You'll need to locate the switch_to routines in the scripts and make the field name change there also.

Quote Reply
Re: Changing field names In reply to
In the release of the relational mod those routines had been moved to the format.pl. I just made the change and all works beautifully now. Thanks so much. It is so easy to do these mods when you do them right Smile

Dale