Gossamer Forum
Quote Reply
Fix Global
Hope someone can fix this global so it also works in dynamic mode, as is if I switch to dymamic mode and I select a category it takes me back to static url.

I suspect that a change needs to be made here.

$output .= qq|<option value="$CFG->{build_root_url}/| . $db->as_url($safe_full) . qq|">$back</option>|. "\n";}





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>Hop to Category</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;
}

Happy Holidays To All
Quote Reply
Re: [rascal] Fix Global In reply to
sub {
my ($category,$output);
my $db= $DB->table('Category') || return $GT::SQL::error;
$db->select_options('ORDER BY Full_Name') || return $GT::SQL::error;
my $sth = $db->select( ['ID','Full_Name', 'CatDepth', 'Number_of_Links'] ) || 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>Website Categories</option>\n|;
while (my ($id,$full_name, $depth, $cnt) = $sth->fetchrow_array) {
my $safe_full = $full_name;
my @cut = split /\//, $full_name;
my $back = '';
for (my $i=0; $i < $#cut; $i++) {
$back .= q|&nbsp;&nbsp;|;
}
$back .= $cut[$#cut];
$output .= qq|<option value="$CFG->{build_root_url}/| . $db->as_url($safe_full) . qq|/$CFG->{build_index}">$back ($cnt)</option>|. "\n";
}
$output .= "</select>\n";
return \$output;
}


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

try this one


Sandra Roussel
Chonsa Group Design - Fresh Start Housing
Quote Reply
Re: [SandraR] Fix Global In reply to
Thanks,

do you know how to bold the main categories?
Quote Reply
Re: [rascal] Fix Global In reply to
You might want to ask Andy: This is the code I use but not for the drop down and it bolds the main category and number of links.... Andy is good at combining the global.
=================================================

sub {
# -------------------------------------------------------------------
my $tags = shift;
my $cat_db = $DB->table('Category');
$cat_db->select_options ('ORDER BY Full_Name');

my $sth = $cat_db->select (['Full_Name','ID','Name','CatDepth','Number_of_Links','Has_New_Links','Has_Changed_Links'] );
my $output=qq~<table width="100%"><tr valign=top><td width="50%"><table>~;
my $i=0;
while (my ($cat,$ID,$heading,$depth,$cnt,$new,$changed) = $sth->fetchrow_array) {
$i++;
my $url1 = $cat_db->as_url($cat);
$output.= qq~<tr><td>~;
my $depth = ($cat =~ tr/\///);
if ($depth > 0){
$output .= "&nbsp;&nbsp;"x$depth."<font size=-1>";
} else { $output.="<b>"; }
$output.=qq~<a href="$CFG->{build_root_url}/$url1" class="toc">$heading</a> ($cnt)~;
if ($new eq "Yes") { $output .= qq| <span class="new-item"><span>new</span></span> |; }
if ($changed eq "Yes") { $output .= qq| <span class="updated-item"><span>updated</span></span> |; }
if ($depth > 0){
$output .= "</font>";
} else {$output.="</b>";}
$output.=qq~</td></tr>~;
if (($i eq '90')){ $output.=qq~</table></td><td width="50%"><table align=top>~;}
}
$output.="</table></td></tr></table>";
return $output;
}


Sandra Roussel
Chonsa Group Design - Fresh Start Housing
Quote Reply
Re: [SandraR] Fix Global In reply to
Anyone?
Quote Reply
Re: [rascal] Fix Global In reply to
Hi rascal,

How about change the url in the value of the select box. Something like below
### this should be put outside the loop(above the while statement)

my $preurl = "$CFG->{build_root_url}/";
if($IN->param('d'){
$preurl="
$CFG->{db_cgi_url}/page.cgi?d=1;g=";
}

### this is changed line
$output .= qq|<option value="$preurl| . $db->as_url($safe_full)

Hope that helps!

Cheers,



Cheers,

Dat

Scripts installation and plugin creation
Plugins

Last edited by:

tandat: Jan 17, 2007, 10:23 PM
Quote Reply
Re: [tandat] Fix Global In reply to
Thanks tandat,

But I can get it to work, do I have the changes in the right place?

sub {
my ($category,$output);
my $db= $DB->table('Category') || return $GT::SQL::error;
$db->select_options('ORDER BY Full_Name') || return $GT::SQL::error;
my $sth = $db->select( ['ID','Full_Name', 'CatDepth', 'Number_of_Links'] ) || 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>Website Categories</option>\n|;
my $preurl = "$CFG->{build_root_url}/";
if($IN->param('d'){
$preurl="$CFG->{db_cgi_url}/page.cgi?d=1;g=";
}
while (my ($id,$full_name, $depth, $cnt) = $sth->fetchrow_array) {
my $safe_full = $full_name;
my @cut = split /\//, $full_name;
my $back = '';
for (my $i=0; $i < $#cut; $i++) {
$back .= q|&nbsp;&nbsp;|;
}
$back .= $cut[$#cut];
$output .= qq|<option value="$preurl| . $db->as_url($safe_full) . qq|/$CFG->{build_index}">$back ($cnt)</option>|. "\n";
}
$output .= "</select>\n";
return \$output;
}
Quote Reply
Re: [rascal] Fix Global In reply to
Hi,

For the preurl, please just change like below. There is a missing ) in the if statement.

if($IN->param('d')){
$preurl="$CFG->{db_cgi_url}/page.cgi?d=1;g=";
}

Cheers,



Cheers,

Dat

Scripts installation and plugin creation
Plugins
Quote Reply
Re: [tandat] Fix Global In reply to
Thanks tandat, it now works.
Quote Reply
Re: [rascal] Fix Global In reply to
In Reply To:
Thanks,

do you know how to bold the main categories?
Hi,

I just sent this to rascal via PM, but thought it would be worth posting here too.

Code:
sub {

my ($category,$output);

my $rootcatcolor = q|green|; # red / blue / orange etc - or hex colors

my $db= $DB->table('Category') || return $GT::SQL::error;
$db->select_options('ORDER BY Full_Name') || return $GT::SQL::error;
my $sth = $db->select( ['ID','Full_Name', 'CatDepth', 'Number_of_Links'] ) || return $GT::SQL::error;

$output .= qq|
<select name="nnn-DeptSelect" onchange="top.location=this.options[this.selectedIndex].value" size="1">
<option selected>Hop to a Category</option>
|;

my $preurl;
$IN->param('d') ?
$preurl = "$CFG->{build_root_url}/" :
$preurl = "$CFG->{db_cgi_url}/page.cgi?d=1;g=";

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

for (my $i=0; $i < $#cut; $i++) {
$back .= q|&nbsp;&nbsp;|;
}

$back .= $cut[$#cut];

if ($#cut < 1) {
$output .= qq|<option style="color: $rootcatcolor" value="$preurl| .
$db->as_url($safe_full) .
qq|/$CFG->{build_index}">$back ($cnt)</option>|. "\n";
} else {
$output .= qq|<option value="$preurl| .
$db->as_url($safe_full) .
qq|/$CFG->{build_index}">$back ($cnt)</option>|. "\n";
}
}

$output .= qq|</select>\n|;
return \$output;
}

NB: This doesn't make root categories bold, it lets you change the colour of the root categories (just edit $rootcatcolor at the top of the global).

AFAIK, its not actually possible to use "weights" inside a <option ..></option> tag - and I've sure tried =)


Hope that helps someone.

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