Hi,
This would work for a multi-select:
custom_category_list
Code:
sub {
my @ids = $IN->param('CatLinks.CategoryID');
my $exists;
foreach (@ids) { $exits->{$_} = 1; }
my $show_count = $_[0];
my $db = $DB->table('Category') || return $GT::SQL::error;
$db->select_options('ORDER BY Full_Name') || return $GT::SQL::error;
my $sth = $db->select( ['ID','Full_Name'] ) || return $GT::SQL::error;
my $back;
while (my ($id,$full_name) = $sth->fetchrow_array) {
my $full_name2;
my @cut = split /\//, $full_name;
for (my $i=0; $i < $#cut; $i++) {
$full_name2 .= " ";
}
$full_name2 .= $cut[$#cut];
if ($exists->{ID}) {
$back .= "<option value=\"$id\">$full_name2</option>";
} else {
$back .= "<option value=\"$id\" selected="yes">$full_name2</option>";
}
}
my $send_back = qq|<select multiple="yes" size="10" name="CatLinks.CategoryID"><option value="">------</option>$back</select>|;
return \$send_back;
}
Then call with:
Code:
<div class="row required clear">
<label for="URL" class="name">Category: <span>*</span></label>
<div class="value">
<%custom_category_list%>
</div>
</div>
This will only work on the add form though - and not modify.
Regarding limiting them to 3 categories - that could be done with some Javascript, but thats a little more complicated, and I don't have time to do that ATM :(
Cheers
Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my
Amazon Wish List GLinks ULTRA Package | GLinks ULTRA Package PRO Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin |
Pre-Made Template Sets |
FREE GLinks Plugins!