Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Walk-through how to Add Select Menu?

(Page 2 of 2)
> >
Quote Reply
Re: [minesite] Walk-through how to Add Select Menu? In reply to
Ya, the easy way is;

Just before;

return $form;

Add;

$form =~ s|\Q<option value="">---</option>|<option value="">-what you want here</option>|;

It may require a little tweak, but should work =)

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Walk-through how to Add Select Menu? In reply to
Thanks Andy

What about auto selecting the first item in the drop down list instead.

Regards

minesite
Quote Reply
Re: [minesite] Walk-through how to Add Select Menu? In reply to
Thats not as easy :)

First, you would need to "split" the HTML really. So something like;

Code:
my @entries = split /\</option\>/, $html;

Then, edit the first entry;

Code:
$entries[1] =~ s|<option value=\"(.*?)\">(.*?)</option>|<option value="$1" selected="yes">$2</option>|;

Then, joing back together;

Code:
my $html = join("</option>\n",@entries);

However, this will screw up with no values are passed in. So you'd probably need;

Code:
sub {

my $column = $_[0];
my $selected = $_[1];
my $table = $DB->table('Users');
my %hash;
my $i = 0;
my $names = $table->form_names->{$column};
my $vals = sort $table->form_values->{$column};
for my $val (@$vals) {
$hash{$val} = $names->[$i++];
}

my $html = $DB->html($table, $IN);
my $form = $html->select({
name => "$column",
values => \%hash,
value => $selected });

$form =~ s|\Q<option value="">---</option>|<option value="">-what you want here</option>|;

if (!$IN->param($column)) {
my @entries = split /\</option\>/, $form =;
$entries[1] =~ s|<option value=\"(.*?)\">(.*?)</option>|<option value="$1" selected="yes">$2</option>|;
$form = join("</option>\n",@entries);
}

return $form;
}

Note, this is untested ;) (and written on after a bit of a drunken bank holiday weekend =)).

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates

Last edited by:

Andy: May 29, 2006, 3:55 PM
Quote Reply
Re: [Andy] Walk-through how to Add Select Menu? In reply to
In Reply To:
Note, this is untested ;) (and written on after a bit of a drunken bank holiday weekend =)).
Cheers

Hi Andy

Hope the day after isn't to bad.

I get the following error, it's on the add form.

Quote:
Links (23501): Links::environment called at /admin/Links.pm line 712 with no arguments.
Links (23501): Links::fatal called at /admin/GT/Config.pm line 619 with arguments
(Bizarre copy of HASH in sassign at /admin/GT/Config.pm line 619.
).
Links (23501): Links::Utils::format_title called at GT::Template::_call_func line 766 with arguments
(ARRAY(0x86f9408), separator, > , no_escape_separator, [undef], include_home, 1, link_type, 2).
Links (23501): GT::Template::_call_func called at /admin/templates/luna/compiled/add.html.compiled line 550 with arguments
(GT::Template=HASH(0x86f2efc), Links::Utils::format_title, 1, ARRAY(0x86f9408), separator, > , no_escape_separator, [undef], include_home, 1, link_type, 2).
Links (23501): GT::Template::parsed_template called at /admin/GT/Template.pm line 552 with arguments
(GT::Template=HASH(0x86f2efc)).
Links (23501): GT::Template::_parse called at /admin/GT/Template.pm line 145 with arguments
(GT::Template=HASH(0x86f2efc), add.html, HASH(0x86fbcf4)).
Links (23501): GT::Template::parse called at /admin/Links.pm line 445 with arguments
(GT::Template, add.html, ARRAY(0x86f47fc), HASH(0x86fbcf4)).
Links (23501): Links::user_page called at /admin/Links/SiteHTML.pm line 307 with arguments
(add.html, HASH(0x86fe034), HASH(0x86fbcf4)).
Links (23501): Links::SiteHTML::__ANON__ called at /admin/GT/Plugins.pm line 133 with arguments
(HASH(0x86fe034), [undef]).
Links (23501): GT::Plugins::dispatch called at /admin/Links/SiteHTML.pm line 27 with arguments
(GT::Plugins=HASH(0x83421cc), site_html_add, CODE(0x86fdf68), HASH(0x86fe034), [undef]).
Links (23501): Links::SiteHTML::display called at /admin/Links/User/Add.pm line 171 with arguments
(add, HASH(0x86fe034)).
Links (23501): Links::User::Add::handle called at /admin/GT/Plugins.pm line 133 with no arguments.
Links (23501): GT::Plugins::dispatch called at add.cgi line 26 with arguments
(GT::Plugins=HASH(0x83421cc), handle_add, CODE(0x8187b9c)).

Regards

minesite
Quote Reply
Re: [minesite] Walk-through how to Add Select Menu? In reply to
Oops, can you try the following?

I had $html where there should have been $form <G>

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Walk-through how to Add Select Menu? In reply to
Following details, please note I changed
my $table = $DB->table('Users'); to
my $table = $DB->table('Links');

Quote:
A fatal error has occured:

Bizarre copy of HASH in sassign at /admin/GT/Config.pm line 619.

Please enable debugging in setup for more details.

Stack Trace
======================================
Links (25122): Links::environment called at /admin/Links.pm line 712 with no arguments.
Links (25122): Links::fatal called at /admin/GT/Config.pm line 619 with arguments
(Bizarre copy of HASH in sassign at /admin/GT/Config.pm line 619.
).
Links (25122): Links::Utils::format_title called at GT::Template::_call_func line 766 with arguments
(ARRAY(0x86f94d0), separator, > , no_escape_separator, [undef], include_home, 1, link_type, 2).
Links (25122): GT::Template::_call_func called at /admin/templates/luna/compiled/add.html.compiled line 550 with arguments
(GT::Template=HASH(0x87032ec), Links::Utils::format_title, 1, ARRAY(0x86f94d0), separator, > , no_escape_separator, [undef], include_home, 1, link_type, 2).
Links (25122): GT::Template::parsed_template called at /admin/GT/Template.pm line 552 with arguments
(GT::Template=HASH(0x87032ec)).
Links (25122): GT::Template::_parse called at /admin/GT/Template.pm line 145 with arguments
(GT::Template=HASH(0x87032ec), add.html, HASH(0x86fc1a8)).
Links (25122): GT::Template::parse called at /admin/Links.pm line 445 with arguments
(GT::Template, add.html, ARRAY(0x86f4ed8), HASH(0x86fc1a8)).
Links (25122): Links::user_page called at /admin/Links/SiteHTML.pm line 307 with arguments
(add.html, HASH(0x86fe888), HASH(0x86fc1a8)).
Links (25122): Links::SiteHTML::__ANON__ called at /admin/GT/Plugins.pm line 133 with arguments
(HASH(0x86fe888), [undef]).
Links (25122): GT::Plugins::dispatch called at /admin/Links/SiteHTML.pm line 27 with arguments
(GT::Plugins=HASH(0x83421d4), site_html_add, CODE(0x86fc238), HASH(0x86fe888), [undef]).
Links (25122): Links::SiteHTML::display called at /admin/Links/User/Add.pm line 171 with arguments
(add, HASH(0x86fe888)).
Links (25122): Links::User::Add::handle called at /admin/GT/Plugins.pm line 133 with no arguments.
Links (25122): GT::Plugins::dispatch called at add.cgi line 26 with arguments
(GT::Plugins=HASH(0x83421d4), handle_add, CODE(0x8187ba4)).
Code:
sub {
my $column = $_[0];
my $selected = $_[1];
my $table = $DB->table('Links');
my %hash;
my $i = 0;
my $names = $table->form_names->{$column};
my $vals = sort $table->form_values->{$column};
for my $val (@$vals) {
$hash{$val} = $names->[$i++];
}
my $html = $DB->html($table, $IN);
my $form = $html->select({
name => "$column",
values => \%hash,
value => $selected });
$form =~ s|\Q<option value="">---</option>|<option value="">-what you want here</option>|;
if (!$IN->param($column)) {
my @entries = split /\</option\>/, $form =;
$entries[1] =~ s|<option value=\"(.*?)\">(.*?)</option>|<option value="$1" selected="yes">$2</option>|;
$form = join("</option>\n",@entries);
}
return $form;
}

Regards

minesite
Quote Reply
Re: [minesite] Walk-through how to Add Select Menu? In reply to
Any idea on what's causing the above error.?

Thanks

Regards

minesite
> >