Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Dropdown menu on search page listing values of a global

Quote Reply
Dropdown menu on search page listing values of a global
Hi everybody,

in the following thread:

http://www.gossamer-threads.com/perl/gforum/gforum.cgi?post=190782

Alex gave a wonderful solution to make categories available in extended search.

The code again:
-------
Links Only in: <select name="catid"><option value="">All</option><%top_categories%></select>

and then in your globals add:

top_categories =>

------------------------------------------------------------------------Code
------------------------------------------------------------------------

sub {
my $cat_db = $DB->table('Category');
$cat_db->select_options ("ORDER BY Full_Name DESC");
my $sth = $cat_db->select ( { FatherID => 0 });
my $output = '';
while (my $cat = $sth->fetchrow_hashref) {
$output .= "<option value='$cat->{ID}'>$cat->{Name}</option>";
}
return $output;
}
----------------------

This works fine. Many thanks to Alex!!!

What do I have to change for listing the values of a global instead of the values in the field of the links table?

I need the values of the global because they are available in different languages.

The code of the global:
----------------
sub {
my $tags = GT::Template->tags;
my $e = qq|<select name="Type" multiple size="4">|;
my %values = (
Produzent => 'Produzent',
Handel => 'Handel',
Dienstleistung => 'Dienstleistung',
Zulieferer_Industrie => 'Zulieferer - Industrie',
Zulieferer_Handwerk => 'Zulieferer - Handwerk',
Keramikbedarf => 'Keramikbedarf',
Forschung => 'Forschung - Materialpr&uuml;fung',
Hochschule => 'Hochschule',
Schule => 'Schule',
Museum => 'Museum',
Messe_Marktveranstalter => 'Messe - Marktveranstalter',
Verband => 'Verband',
Verlag => 'Verlag',
Sonstige => 'Sonstige'
);
my $l = $tags->{Type} || '';
foreach my $k ( sort keys %values ) {
my $is_selected = $l eq $k ? "selected" : "";
$e .= qq{<option value="$k" $is_selected>$values{$k}</option>};
}

$e .= "</select>";
return $e;
}
----------------

Building my own select field that searches directly in the table worked for searching, but there is no option to list all and to leave this search option blank.


Thanks for any help,
Lars