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

Dynamically generate a drop-down field for a field...

(Page 2 of 2)
> >
Quote Reply
Re: [kailew] Dynamically generate a drop-down field for a field... In reply to
Cool

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!
Quote Reply
Re: [Andy] Dynamically generate a drop-down field for a field... In reply to
Hi,

now I have another question ...

Code:
sub {
my $back = qq|<select name="Ort">|;
my $tbl = $DB->table('Links');
$tbl->select_options('ORDER BY Ort ASC');
my $sth = $tbl->select();
while (my $hit = $sth->fetchrow_hashref) {
$back .= qq|<option value="$hit->{ID}">$hit->{Ort}</option>|;
}
$back .= q|</select>|;
}

If I understand this code rigth, then the number of rows in the select-field is equal to the number of entries in my db?

But I have the problem, that I have some duplicate values which are now shown as often as they are used in the field. But in the select-field I like to display a value only one time. And there is another problem when I have less values in the field than records in the db. Then empty rows are displayed in the select-field.

Kai
___________________________________________
http://www.westalgarve.de
http://www.portugalforum.org
http://www.portugal-links.de
Quote Reply
Re: [kailew] Dynamically generate a drop-down field for a field... In reply to
Hi,

To make them only show up once each, you could change;

Code:
my $sth = $tbl->select();

..to;

Code:
my $sth = $tbl->select( ['DISTINCT(Ort)'] );

Not really sure about your other issue though :/

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!
Quote Reply
Re: [Andy] Dynamically generate a drop-down field for a field... In reply to
Hi Andy,

seems to work, but now I like to have the option for the search that the field is left empty: "---" or something like this ...

Kai
___________________________________________
http://www.westalgarve.de
http://www.portugalforum.org
http://www.portugal-links.de
Post deleted by kailew In reply to
Quote Reply
Re: [kailew] Dynamically generate a drop-down field for a field... In reply to
That ones simple <G>

Just change;

Code:
my $back = qq|<select name="Ort">|;

to;

Code:
my $back = qq|<select name="Ort"><option value="">---</option>|;

Angelic

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!
Quote Reply
Re: [Andy] Dynamically generate a drop-down field for a field... In reply to
Hello,
can this mod be extended to pull values of a field from a NEW table that I have created "clients" and show these values in a pull-down menu in the add/modify in the admin ....
somthing like:
http://www.gossamer-threads.com/...;;page=unread#unread

Thank you in advance for your help
Mark
Quote Reply
Re: [Mark2] Dynamically generate a drop-down field for a field... In reply to
Hi,

The bit to make a dropdown based on the new table would be a piece of cake. The bit about getting it into the admin panel is another matter - afraid I'm not sure how you would do that.

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!
Quote Reply
Re: [Andy] Dynamically generate a drop-down field for a field... In reply to
Hi Andy,
Thanks for your response... actually, Dat had create it a plugin that works to soem extend; however, it is still missing something as the new field shows in the admin add/modify but outside the table (above the ID) in the form... then there is the issue it is not pulling the information from another table...
you can see the plug in down in: http://www.gossamer-threads.com/...uest=17977306#295846

wondering if yours can be compined with his to generate a plugin that allow the admin to show related fields in the admin side... that will be very helpful to allow admins to add related information for a link/category that has extended information in another table... either of the level of code or on the level or telational tables.

thanks again
Eiad
Quote Reply
Re: [Mark2] Dynamically generate a drop-down field for a field... In reply to
Hi,

Quote:
actually, Dat had create it a plugin that works to soem extend;

Ah, I see =)

Quote:
wondering if yours can be compined with his to generate a plugin that allow the admin to show related fields in the admin side... that will be very helpful to allow admins to add related information for a link/category that has extended information in another table... either of the level of code or on the level or telational tables.
Afraid I don't have much time at the moment to start looking into things like that (only small globals/minor issues on this forum). Got quite a few custom projectsd on the go, and can't really dedicate the time to try and work out whats going on - sorry :(

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!
Quote Reply
Re: [Andy] Dynamically generate a drop-down field for a field... In reply to
Hi Andy,

I use your Global like this :

Code:
sub {
my $field = $_[0];
my $table = $DB->table('Links');
my $cond = new GT::SQL::Condition('City','=','CityName');
$table->select_options('ORDER BY City ASC');
my $sth = $table->select($cond, ["DISTINCT($field)"] );
my $back = qq||;
while (my ($name) = $sth->fetchrow_array) {
$back .= qq|<a href="$name">$name</a> - |;
}
return $back;
}
But, I would like to obtain 2 information to build my link like this :

<a href= "$name1">$name2</a>

You think that it is possible ?

Thank you for your assistance.

Mick

Quote Reply
Re: [MJ_] Dynamically generate a drop-down field for a field... In reply to
Hi,

Can't remember without trying (just got back from a long weekend away), but you could try replacing:
Code:
my $sth = $table->select($cond, ["DISTINCT($field)"] );
my $back = qq||;
while (my ($name) = $sth->fetchrow_array) {
$back .= qq|<a href="$name">$name</a> - |;
}

..with:
Code:
my $sth = $table->select($cond, ["DISTINCT($field)",'Otherfieldname'] );
my $back = qq||;
while (my ($name,$other) = $sth->fetchrow_array) {
$back .= qq|<a href="$other">$name</a> - |;
}

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!
Quote Reply
Re: [Andy] Dynamically generate a drop-down field for a field... In reply to
Hi Andy,

Thank you, that functions perfectly ! Smile

Mick
> >