Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Re: [nir] List of category

Quote Reply
Re: [nir] List of category In reply to
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 .= "&nbsp;&nbsp;";
}

$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!
Subject Author Views Date
Thread List of category nir 5316 Jun 25, 2008, 5:46 AM
Thread Re: [nir] List of category
Andy 5185 Jun 25, 2008, 6:04 AM
Thread Re: [Andy] List of category
nir 5188 Jun 25, 2008, 6:15 AM
Thread Re: [nir] List of category
Andy 5206 Jun 25, 2008, 6:23 AM
Thread Re: [Andy] List of category
nir 5194 Jun 25, 2008, 6:49 AM
Thread Re: [nir] List of category
Andy 5190 Jun 25, 2008, 6:57 AM
Thread Re: [Andy] List of category
nir 5177 Jun 25, 2008, 7:03 AM
Thread Re: [nir] List of category
Andy 5194 Jun 25, 2008, 7:07 AM
Post Re: [Andy] List of category
nir 5175 Jun 25, 2008, 7:11 AM