Gossamer Forum
Home : Products : DBMan : Customization :

user-chosen display

Quote Reply
user-chosen display
I would like an "easy" way for the user to decide himself which fields to display for the record display.

I know how to set up multiple record displays with if then statements (like the if SSI=1 then display=foo) but the person I'm setting this database up for wants a seemingly endless list of display choices.

I would like him to be able to select checkboxes or something for the fields he wishes to display. So if tomorrow he decides he needs yet ANOTHER option, he can just click the checkboxes.

Any suggestions?
Sigrid
Quote Reply
Re: [sigrid] user-chosen display In reply to
You could setup radio fields which will provide the user a choice when adding their record which field to display.

For instance providing choices to display address and phone fields:

'Address1' => [ 5,'alpha',30,80,1,'',''],
'Phone' => [12,'alpha',15,20,1,'',''],

'showadd' => [24,'alpha',0,3,1,'Yes','Yes|No'], ## show address
'showphn' => [25,'alpha',0,3,1,'No','Yes|No'], ## show phone

%db_radio_fields = (
'showadd' => 'Yes,No',
'showphn' => 'Yes,No'
);

In your html_record_form you could use something like:

<TR><TD valign=top><$font><B>Address1:</B></FONT></TD><TD><input type="TEXT" name="Address1" SIZE="30" VALUE="$rec{'Address1'}" MAXLENGTH="80"><BR>&nbsp; &nbsp; <$font>Display? |; print &build_radio_field("showadd",$rec{'showadd'}); print qq|</font></TD></TR>

<TR><TD><$font><B>Phone:</B></FONT></TD>
<TD><input type="TEXT" name="Phone" SIZE="15" VALUE="$rec{'Phone'}" MAXLENGTH="20"> &nbsp; <$font>Display? |; print &build_radio_field("showphn",$rec{'showphn'}); print qq|</font></TD></TR>


Then in your html_record or html_record_long you would use:

|;
if ($rec{'showadd'} eq "Yes") { print qq|$rec{'Address1'}<BR>|; }
print qq|


|;
if ($rec{'showphn'} eq "Yes") { print qq|Phone: $rec{'Phone'}<BR>|;}
print qq|

or you could use something like the following to show alternate text:

|;
if ($rec{'showphn'} eq "Yes") { print qq|Phone: $rec{'Phone'}<BR>|;
}
else {
print qq| Phone: N/A<BR>|;
}
print qq|

I think using radio options for me makes it more clear when they choose which fields to display, but I'm sure checkboxes would work just as well.

Hope this helps

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] user-chosen display In reply to
hmm, that isn't exactly what I want, but thanks for the suggestion. Lst me explain what it is.

It is a database of people in an association. The records have each person's address, email address, name, and fields for about 30 committees which the person could be chair, member, etc. of.

I would like the database to display the records in several ways (similar to the short/long display) but I want the various displays to be customizable on the fly. In otherwords, I don't want to set up a different record display for x number of fields (I think there are about 50 fields... so what is that 2500 different combinations of what fields to display?) I want the searcher to search on committee, for example, and also check off "only display the list of emails" so they would just get a list of email addresses for that committee.

Sometimes the searcher will want to display all the names of the people on the committee without the links to the long records. Sometimes they may want to display all the names and addresses, and nothing else.

See what I'm getting at? It would be easy just to set up something like you suggested, if he didn't want so many dang display options.
Quote Reply
Re: [sigrid] user-chosen display In reply to
Sounds like you will need to setup the various display options and then provide a link to each display.

You may want to search the FAQ under the section Viewing for ideas.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] user-chosen display In reply to
You can display columns on the fly, but it requires a bit of work to build up your select fields for the column headers in sub html_view_success. For the fields to be built on the fly in sub html_record (this is naturally assuming your are using the long/short mod), the key is to use assuming you are passing four column names in an array @header:

for ($i=0; $i<=3; $i++) {
$rec{$header[$i]}
}

instead of the normal $rec{'MyField'}

Hope that helps...