Gossamer Forum
Home : Products : DBMan : Customization :

Abbreviations Expanded When Data is Displayed?

Quote Reply
Abbreviations Expanded When Data is Displayed?
 
I am working on a directory of homeless shelters ( http://www.agrm.org/missions/ ) and have run into a dilemma.

The data is being exported from a database in which codes are assigned for the various programs offered at the shelters. For instance, "ED6" denotes that a particular center offers an "English as a Second Language" educational program.

Is there a way to set up DBman so that these codes can be expanded into the full text explanations of the programs when they are displayed? (all of the codes are in a single field, separated with commas)


Michael Liimatta, Education Director
AGRM (http://www.agrm.org)
Kansas City MO USA
Quote Reply
Re: Abbreviations Expanded When Data is Displayed? In reply to
In the html_record sub-routine of html.pl, you would need to include some code like the following (under my (%rec) = @_):

$rec{'field_name'} =~ s/ED6/English as a Second Language/;

Basically, this looks at the value of field_name and replaces each occurance of ED6 with English as a Second Language

- Mark

Astro-Boy!!
http://www.zip.com.au/~astroboy/
Quote Reply
Re: Abbreviations Expanded When Data is Displayed? In reply to
 
Thanks!!

So. would I then add a separate line with similar formatting for each of the various codes?

Michael Liimatta, Education Director
AGRM (http://www.agrm.org)
Kansas City MO USA
Quote Reply
Re: Abbreviations Expanded When Data is Displayed? In reply to
Yep.

Regards,

Eliot Lee
Quote Reply
Re: Abbreviations Expanded When Data is Displayed? In reply to
 
I tried the recommendation and it easily replaces a single code with the longer explanation. (ED6 becomes English as a Second Language).

But I need to replace a strings of 10-20 of them that look like this:

CH,CY1,DV1,DV2,ED1,ED2,ED3,ED6,FD1,ID2,MN1,MN2,MN4,RX1,SG,WF1,WF10,WF3,WF4,WF8

I'd also like to be able to replace the "," with either "<BR>" or "<LI>".

Thanks for the help!!

Michael Liimatta, Education Director
AGRM (http://www.agrm.org)
Kansas City MO USA
Quote Reply
Re: Abbreviations Expanded When Data is Displayed? In reply to
The problem is that each of these codes have unique values, right? Welp, there is really no other way UNLESS you convert all the code values off-line in the Excel spreadsheet before exporting the data and uploading it into DBMAN.

Good luck!

Regards,

Eliot Lee
Quote Reply
Re: Abbreviations Expanded When Data is Displayed? In reply to
Use the following code, in your default.cfg and you should get what you need! I know how u feel, I had the same problem!

code default.cfg
---------------------
%db_select_option_fields = (
Field => 'English Second language|ED6,French|ABC,German|123,Spanish|345'
);
---------------------
code html.pl
---------------------
<td align="Right" valign="TOP" width="104"> <$font>Field: </td>
<td valign="TOP" colspan="5"> |; print &build_select_option_fields ("Field",
"$rec{'Field'}"); print qq|</td>
---------------------
Just add your select fields, and the code as 'option|code,
Hope this helps
Ben

Quote Reply
Re: Abbreviations Expanded When Data is Displayed? In reply to
 
This sounds exactly like the solution I need, thanks.

When I tried to implement it, though, I got this error message:

fatal error: Undefined subroutine &main::build_select_option_fields called at ./data_html.pl line 560.

I wonder if maybe you've got a custom subroutine that has to be in db.cgi too.



Michael Liimatta, Education Director
AGRM (http://www.agrm.org)
Kansas City MO USA
Quote Reply
Re: Abbreviations Expanded When Data is Displayed? In reply to
Errrrr yeah, sorry, fogot about that! try this
db.cgi
--------------
sub build_select_option_fields {
# --------------------------------------------------------
# Builds a SELECT field based on information found
# in the database definition. Parameters are the column to build
# and a default value (optional).

my ($column, $value) = @_;
my (@fields, $ouptut, $op_text, $op_value);

@fields = split (/\,/, $db_select_option_fields{$column});
if ($#fields == -1) {
$output = "error building select field: no select fields
specified in config for field '$column'!";
}
else {
$output = qq|<SELECT NAME="$column"><OPTION>---|;
foreach $field (@fields) {
@option = split(/\|/, $field);
$op_text = @option[0];
$op_value = @option[1];
$op_text eq $value ?
($output .= "<OPTION SELECTED value=\"$op_value\">$op_text\n") :
($output .= "<OPTION value=\"$op_value\">$op_text");
}
$output .= "</SELECT>";
}
return $output;

}
-----------------
Hope this works
Ben