Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Add another category select to admin add link form

Quote Reply
Add another category select to admin add link form
Hello,

Based on a response to my previous post, I created a field named 'builddet_cat' in my links table. The category id I enter here is being used to create the title_linked in my detailed pages. I'm currently manually entering the id number of the category, but that's an extreme nuisance to have to first look up the category id every time.

I'd like to add a second category list to the admin links add form, but can't figure out where to edit <%form%> to include it and be prefilled with the category fields as the labels and the id number as the value. Something like this:

Name:[textfield]
URL:[textfield[/url]]
Description: [textarea]
Detail: [textarea]
Categories: [select multiple]
Build Category: [select]

Any help you can offer would be greatly appreciated.

All the best,

Jasmine
Quote Reply
Re: [Jasmine] Add another category select to admin add link form In reply to
Hi,

I believe you need to modify the Link.pm file in the admin/Links directory. Find sub form{

and add in before the GT::Plugins::dispatch:

$self->{code}->{Category2} = \&SomeModule::admin_cat_select_list_2;

(Category2 being the name of the select list)

Then make a module called SomeModule and put a function something like this in it:

sub admin_cat_select_list_2 {
my $html=shift;
my $cols=shift;
my $values=shift;

my $selname='Category2';
my $existing=$values->{$selname};
my $db=$Links::DB->table('Category');
my $sth=$db->select(['Full_Name']);
my $str=qq|<select name="$selname"><option value="">---</option>|;
while (my @row=$sth->fetchrow_array){
$str.=qq|<option value="$row[0]"|;
if ($existing eq $row[0]) {
$str.=" selected ";
}
$str.=qq|>$row[0]</option>|;
}
$str.="</select>";
return "<tr><td>$selname</td><td>$str</td></tr>";
}

and change Category2 to whatever you want the field name to be called.

It's not trivial to do this, but that should work.

Mel
Mel Goulet
Developer - Gossamer Threads, Inc.
Quote Reply
Re: [Mel_g] Add another category select to admin add link form In reply to
Hello Mel,

Worked like a charm! THANK YOU!

Jasmine