Gossamer Forum
Quote Reply
Drop Down Menu
I found this global on the board and it works wonderfully in Static mode.

Can someone help me to get this global to work in Dynamic and only show Top Level Categories?

In dynamic the drop down does show but does not go anywhere. No linking.

=========================================================================

sub {
my ($category,$output);
my $db = $DB->table('Category') || return $GT::SQL::error;
$db->select_options('ORDER BY Full_Name','LIMIT 100') || return $GT::SQL::error;
my $sth = $db->select( ['ID','Full_Name'] ) || return $GT::SQL::error;
$output .= qq|<select name="nnn-DeptSelect" onchange="top.location=this.options[this.selectedIndex].value" size="1">\n|;
$output .= qq|<option selected>Choose</option>\n|;

while (my ($id,$full_name) = $sth->fetchrow_array) {
my $safe_full = $full_name;
my @cut = split /\//, $full_name;

my $back = '';
for (my $i=0; $i < $#cut; $i++) {
$back .= q| |;
}
$back .= $cut[$#cut];
$output .= qq|<option value="$CFG->{build_root_url}/| . $db->as_url($safe_full) . qq|">$back</option>|. "\n";
}
$output .= "</select>\n";
return \$output;
}


Sandra Roussel
Chonsa Group Design - Fresh Start Housing
Quote Reply
Re: [SandraR] Drop Down Menu In reply to
Try this

It used to work with glinks 2.2 but not tested with 3 and up:

sub {
my $tags = shift;
my $cat_db = $DB->table(\'Category\');
$cat_db->select_options (\'ORDER BY Full_Name\');
my $sth = $cat_db->select ( { FatherID => 0 } );
my $output="";
my $root = [{}];
while (my $root_cat = $sth->fetchrow_hashref) {
push @$root, $root_cat;
}
$output = Links::SiteHTML::display (\'print_cat\', $root);
return $output;
} '
Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory
Quote Reply
Re: [katabd] Drop Down Menu In reply to
Thanks KaTaBd,

But not a thing showed up checked in FF and IE


Sandra Roussel
Chonsa Group Design - Fresh Start Housing
Quote Reply
Re: [SandraR] Drop Down Menu In reply to
sub {
my ($category,$output);
my $db = $DB->table('Category') || return $GT::SQL::error;
$db->select_options('ORDER BY Full_Name','LIMIT 275') || return $GT::SQL::error;
my $sth = $db->select( ['ID','Full_Name'], { FatherID => '0' }) || return $GT::SQL::error;
$output .= qq|<select name="nnn-DeptSelect" onchange="top.location=this.options[this.selectedIndex].value" size="1">\n|;
$output .= qq|<option selected>Choose</option>\n|;
while (my ($id,$full_name) = $sth->fetchrow_array) {
my $safe_full = $full_name;
my @cut = split /\//, $full_name;
my $back = '';
for (my $i=0; $i < $#cut; $i++) {
$back .= q| |;
}
$back .= $cut[$#cut];
$output .= qq|<option value="$CFG->{build_root_url}/| . $db->as_url($safe_full) . qq|">$back</option>|. "\n";}
$output .= "</select>\n";
return \$output;
}
Quote Reply
Re: [rascal] Drop Down Menu In reply to
closer but many errors

sub { my ($category,$output); my $db = $DB->table('Category') || return $GT::SQL::error; $db->select_options('ORDER BY Full_Name','LIMIT 275') || return $GT::SQL::error; my $sth = $db->select( ['ID','Full_Name'], { FatherID => '0' }) || return $GT::SQL::error; $output .= qq|Choose$back\n"; return \$output; }


Sandra Roussel
Chonsa Group Design - Fresh Start Housing
Quote Reply
Re: [SandraR] Drop Down Menu In reply to
Hi,

The global I just posted works, been using it for 2 years.
Quote Reply
Re: [rascal] Drop Down Menu In reply to
I tried it the moment you posted it and I got the above errors?


Sandra Roussel
Chonsa Group Design - Fresh Start Housing
Quote Reply
Re: [SandraR] Drop Down Menu In reply to
It seems like your grlobla is being printed to screen and that is usually due to a typo on the global entry.

check to make sure there are no prefixes or sufixes to the global.
Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory
Quote Reply
Re: [katabd] Drop Down Menu In reply to
sub {
my ($category,$output);
my $db = $DB->table('Category') || return $GT::SQL::error;
$db->select_options('ORDER BY Full_Name','LIMIT 275') || return $GT::SQL::error;
my $sth = $db->select( ['ID','Full_Name'], { FatherID => '0' }) || return $GT::SQL::error;
$output .= qq|<select name="nnn-DeptSelect" onchange="top.location=this.options[this.selectedIndex].value" size="1">\n|;
$output .= qq|<option selected>Choose</option>\n|;
while (my ($id,$full_name) = $sth->fetchrow_array) {
my $safe_full = $full_name;
my @cut = split /\//, $full_name;
my $back = '';
for (my $i=0; $i < $#cut; $i++) {
$back .= q||;
}
$back .= $cut[$#cut];
$output .= qq|<option value="$CFG->{build_root_url}/|. $db->as_url($safe_full) . qq|">$back</option>|. "\n";}
$output .= "</select>\n";
return \$output;
}


I finaly got it to work - there were a few spaces it did not like. BUT It still refuses to work in Dynamic, works great in static.


Sandra Roussel
Chonsa Group Design - Fresh Start Housing
Quote Reply
Re: [SandraR] Drop Down Menu In reply to
Sandra,

Make sure that each line of code ends with ; because it does work in Dynamic.

The forum you know does throw the code off a little!
Quote Reply
Re: [rascal] Drop Down Menu In reply to
This one is stumping me:

Why it works in static:

<option value="http://mydomain.com/Antiques">Antiques</option>
<option value="http://mydomain.com/Art">Art</option>
<option value="http://mydomain.com/Automotive">Automotive</option>
<option value="http://mydomain.com/Books">Books</option>for dynamic it needs:
http://mydomain.com/cgi-bin/page.cgi?g=Home___Garden%2FHome_Decor%2FCandles__Candle_Holders%2FAncient_Range%2Findex.html;d=1

Some where its breaking off


Sandra Roussel
Chonsa Group Design - Fresh Start Housing