Gossamer Forum
Home : Products : DBMan : Customization :

pull values for multi select from a file -

Quote Reply
pull values for multi select from a file -
Hi there,
i have several multi selct fields. The idea came up to pull the values from which the user can pick from a file, which itself can be manipulated online by the admin.
What do you think about the idea? Is it possible and how could a solution look like?

Jakob

Quote Reply
Re: pull values for multi select from a file - In reply to
One of these days I'm going to get my whole "select-o-matic" mod done that has every possible permutation of select fields that anyone can think of -- plus about 10 more. Smile

Sure it's possible. It would look a lot like a combination of your current "build multiple select field" plus something similar to "build select field from db" except that you would be accessing a different file.

You could edit the file online, with an "admin-only" function or you could edit it offline. You could set it up so that there was only one file or you could define the file name when you call the subroutine.

There are any number of possibilities.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: pull values for multi select from a file - In reply to
Hi,

I have been working on the problem, however no solution as of yet. Could you give me another hint?
I will have
-several different catagory types - lets name them 1 - 10.
-several values per catergory type (only for the resp category)

I want to be able to edit these online.

Thank you a head of time for every pointer.


Jakob


Quote Reply
Re: pull values for multi select from a file - In reply to
I'm going to point you in the direction of two thread references:

Builds a SELECT field from an external database (sub build_limited_multiple_select_field_from_other_db)

How to use multiple select fields

These can be found in the FAQ noted below under "Fields" and then the subtopic of "Working with Selects".

You may get other ideas from the FAQ also.

Hope this helps

Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: pull values for multi select from a file - In reply to
If you don't find what you need in Lois's FAQ, I can help. I just need to know what you want.

It will take a little time to write this, though. It's pretty involved.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: pull values for multi select from a file - In reply to
Hi,

I'm workin on it....

I first only wanted to pull values from the file... Here is what I am working on:

# --------------------------------------------------------
# Builds a SELECT field from an external database.
# Parameters are
# the column to which the value will be written -- $column
# a default value -- $value
# the height of the select field -- $size (optional)
my ($column, $value, $size, $VerteilerNo) = @_;
my (@fields, $field, @selectfields, $selected, $fieldnum1, $fieldnum2,
@lines, $line, $output, $found, @values);
$size or ($size = 3);
@values = split (/\Q$db_delim\E/,$value);

# The number of the field in the other .db file that holds the
# values you want in your select field
$fieldnum1 = 2;
# The number of the field in the other .db file that holds the Verteiler no.
$fieldnum2 = 1;
# End of things to edit.
for ($i = 0; $i <= $#db_cols; $i++) {
if ($column eq $db_cols[$i]) {
$found = 1;
last;
}
}
if (!$found) {
return "error building select field: no fields specified!";
}
open (DB, "<$db_other_file_name") or &cgierr("Error in build_select_field_from_other_db.
Unable to open $db_other_file_name. Reason: $!");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB> ) {
next if /^#/;
next if /^\s*$/;
$line = $_;
chomp ($line);
@fields = &split_decode ($line);
# if ($fields[$fieldnum2] eq $VerteilerNo) {
if (!(grep $_ eq $fields[$fieldnum1], @selectfields)) {
push (@selectfields, $fields[$fieldnum1]);
}
# }
}
close DB;

$output = qq|<SELECT NAME="$column" MULTIPLE SIZE=$size><OPTION>---|;
foreach $field (sort @selectfields) {
$selected = 0;
foreach $value (@values) {
if ($value eq $field) {
$output .= "<OPTION SELECTED>$field";
$selected = 1;
}
}
unless ($selected) {
$output .= "<OPTION>$field";
}
}
$output .= "</SELECT>";
return $output;
}

However it doesn't pull right.. WHY? What does the field seperator have to be?

The file looks as follows
1|test1|test2:test3:test4

Thank you for the help!

Jakob

Quote Reply
Re: pull values for multi select from a file - In reply to
Hi there,

I solved it!!! Smile

I used your mod sub build_limited_multiple_select_field_from_other_db which was posted a couple months ago to read the values into my multi select and used the new mod Log File Viewer/Editor to view and edit these as a admin.
This version also allows me to write something behind the values in the file as a reminder. It is also possible to habe different values for different fields. I added a field to your mod as criteria.

Should I send you my mod, so you can make a general mod out of it so that other users can use it.

Thank you for all the help!

Jakob

Quote Reply
Re: pull values for multi select from a file - In reply to
Excellent! See, you didn't need me after all. Smile

Go ahead and make up your own mod and submit it to the Resource Center.

JPD
http://www.jpdeni.com/dbman/