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

Automatically Select All Categories

Quote Reply
Automatically Select All Categories
Is there a way to make the add form automatically select all of the categories?

I have two add forms, for one of them (the sponsored form), I want all of the categories automatically selected.
Quote Reply
Re: [Gregorio] Automatically Select All Categories In reply to
ok, got it....

made a global all_selected (partial hack from another post on the boards)....
Code:
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 ( ['ID', 'Full_Name'] );
my $output;
while (my ($cid,$name) = $sth->fetchrow_array) {
$output .= "<input type='hidden' name='CatLinks.CategoryID' value='$cid'>";
}
return $output;
}


Then use <%all_selected%> instead of <%Category%> in Add and Modify.

Again, this mod is to have a link added to ALL categories.