Gossamer Forum
Home : Products : Gossamer Links : Discussions :

allow users to select multiple categories

Quote Reply
allow users to select multiple categories
Is it possible to allow users to select multiple categories when they submit a site? If so, what would the html look like?

Quote Reply
Re: allow users to select multiple categories In reply to
It's more than HTML that you would have to edit. You would basically have to create a plug-in to facilitate this process.

Regards,

Eliot Lee
Quote Reply
Re: allow users to select multiple categories In reply to
does anybody have such kind of plugin ? i really need it !

Quote Reply
Re: allow users to select multiple categories In reply to
Hi,

I played around with add.cgi and found that when I change

$category = $html->get_all_categories(\@ids, 'CatLinks.CategoryID', 1);

to

$category = $html->get_all_categories(\@ids, 'CatLinks.CategoryID', 5);

in sub _category_list

a multi select form field for the category list (with 5 categories displayed) is presented to the user when he submits a new link. Also the selected categories get passed into the database so they appear as selected values in the validate form.

This should be a quick and dirty solution for your problem, although I don't know if there are any unwanted side effects. Just tested it and it worked without any problems here, but:

Unfortunately there seems to be a bug in the validate (at least in my installation of LinksSQL 2.0.3) so only the first value of a multi-select field (be it categories or any other) is saved to the database when validating a link.
So the situation is that the selected values get saved into the database without problems when the user submits a site and they are deleted from the database when validating it ... odd.

NB: Remember, when you edit add.cgi it won't survive any upgrades to newer versions LinksSQL.

Regards
Andreas

--------------------------------------------
http://www.archaeologie-online.de
Quote Reply
Re: allow users to select multiple categories In reply to
so this was never fixed?

Quote Reply
Re: allow users to select multiple categories In reply to
i think you also have to change sub_category_list in modify.cgi.

Another problem is, if you change in sub_category_list

$category = $html->get_all_categories(\@ids, 'CatLinks.CategoryID', 1);
to
$category = $html->get_all_categories(\@ids, 'CatLinks.CategoryID', 3);

you get a 3-row-multiselect-form but you can select as much categories as you want.

so there as to be a way to limit the amount of selected categories.

Quote Reply
Re: allow users to select multiple categories In reply to
"quick and dirty" are the keywords here...hehe!

Regards,

Eliot Lee
Quote Reply
Re: allow users to select multiple categories In reply to
nothing wrong w/ that but the validate bug is still there...so not much point to do this because you will have to manually enter the extra categories or just drop all but the first category.

Quote Reply
Re: allow users to select multiple categories In reply to
I can't imagine why this bug is there, Alex, any ideas?

Quote Reply
Re: [dwh] allow users to select multiple categories In reply to
I've been searching & trying for hours to allow a user to select more than one category for a link being added. I think I've reached the frustration point max and I'm overlooking something very basic...can someone tell me what I need to do here, or at least point me in the right direction?

All I want is user#1 to add a link and select three or four categories for his link, and it will be listed in all of those categories.

I'll be extremely grateful for anyones help,

Steve
Perl Hopefull
Quote Reply
Re: [stilton] allow users to select multiple categories In reply to
Hopefully this will be repaired in the next version. Please? Pretty please? Confirmation anyone?
Quote Reply
Re: [rayhne] allow users to select multiple categories In reply to
After digging for awhile longer, I came up with a solution that will fit my needs for the time being from another post:

Create a new template global and call it something like <%selected_cats%> which willl replace <%Category%> in include_form.html
--------------------------------------------------

sub {
my ($rec) = @_;
my $id = $rec->{ID};
my $db = $DB->table('CatLinks');
my @sids = $db->select ( ['CategoryID'], { 'LinkID' => $id } )->fetchall_list;
my $cat_db = $DB->table('Category');
$cat_db->select_options ('ORDER BY Full_Name ASC');
my $sth = $cat_db->select ( { 'Description' => 'SUB1' }, ['ID', 'Full_Name'] );
my $output;
$output .= "<SELECT MULTIPLE SIZE='5' name='CatLinks.CategoryID'>";
$output .= "<option selected value='3'>Rob</option>";
$output .= "<option selected value='4'>Lisa</option>";
$output .= "<option selected value='5'>Sonya</option>";
$output .= "<option selected value='6'>Sue</option>";
$output .= "<option selected value='7'>Sam</option>";
while (my ($cid,$name) = $sth->fetchrow_array) {
$output .= "<option value='$cid'";
foreach my $sid (@sids) {
if ($sid eq $cid) {
$output .= " selected";
}
}
$output .= ">$name</option>";
}
$output .= "</SELECT>";
return $output;
}
---------------------------------------------------------------

Change the field values to reflect the categories you have. You can use different form types here, I just chose to go with a multiple selection box.

Hope it helps,
Perl Hopefull
Quote Reply
Re: [stilton] allow users to select multiple categories In reply to
this works perfectly