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

Global to display category dropdown...

Quote Reply
Global to display category dropdown...
Hi. Im working on a global that will show a list of the categories... it is as follows;

Code:
sub {

my $category;
my $db = $DB->table('Category') || return $GT::SQL::error;
$db->select_options('ORDER BY Full_Name') || return $GT::SQL::error;
my $sth = $db->select() || return $GT::SQL::error;

while (my ($id,$full_name) = $sth->fetchrow_array) {

my @cut = split /\//, $full_name;
my $back = '';
for (my $i=0; $i < $#cut; $i++) {
$back .= " ";
}

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

}

my $send_back = qq|<select size="1" name="catid"><option value="">------</option>$back</select>|;

return $send_back;

}

The idea of the output would be;

Code:
Name
Sub1
Sub2
Another
Sub
Sub
Test
Test2

The problem is, the above global is giving me a 'compilation' error. Can anyone see my stupid mistake? I've been looking over this global for the last couple of hours... and its completly evaded me :(

TIA

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] Global to display category dropdown... In reply to
Try ['ID','Full_Name'] in the select statement.
Quote Reply
Re: [afinlr] Global to display category dropdown... In reply to
Thanks, but that didn't fix it. I think the main problem, was that I was scoping $back inside a loop, and then calling it outside of that loop (where it doesn't exist). I've fixed it up now :)

Code:
sub {
my $show_count = $_[0];
my $category;
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','Number_of_Links'] ) || return $GT::SQL::error;

my $back;

while (my ($id,$full_name,$numberoflinks) = $sth->fetchrow_array) {

my $full_name2;
my @cut = split /\//, $full_name;
for (my $i=0; $i < $#cut; $i++) {
$full_name2 .= "&nbsp;&nbsp;";
}

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

if ($show_count) {
$full_name2 .= " ($numberoflinks)";
}

$back .= "<option value=\"$id\">$full_name2</option>";

}

my $send_back = qq|<select size="1" name="catid"><option value="">------</option>$back</select>|;

return $send_back;

}

I'm quite impressed with it (seems to be working on the installation I just set it up on, so enjoy Smile).

If you want to show the category counts on it, simply use something like;

Code:
<%global_name('1')%>

...or if you don't want category counts to show;

Code:
<%global_name('0')%>
or
Code:
<%global_name%>

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!

Last edited by:

Andy: Feb 14, 2004, 7:13 AM
Quote Reply
Re: [Andy] Global to display category dropdown... In reply to
I really like this global you made. Cool Thanks very much for sharing it.

--Frank
Quote Reply
Re: [FrankM] Global to display category dropdown... In reply to
No prob :) It just saves a lot of space when listing all your categories , and also saves download speeds for people with slower connections Smile

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] Global to display category dropdown... In reply to
The class dropdownmenu has turned out. Prompt, as now it is necessary to change a code that it also worked (now I see only names of categories, and are necessary in fact also links to pages)

_________________________________________________________________________________________________________________
Web directory and search engine | Dirlist.net Directory - Add your link today.
Quote Reply
Re: [Bigpat] Global to display category dropdown... In reply to
Huh? Unsure

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] Global to display category dropdown... In reply to
I apologize for bad English.
Now generated menu has at me such kind (it is a part of a code.):

<option value="733">&nbsp;&nbsp;Lord_of_the_Rings</option>
<option value="739">&nbsp;&nbsp;Gifts & Occasions</option>

Me interests how to change a code that the menu was such:

<option value="733"><a href="www.bigpat.com/Lord_of_the_Rings/index.shtml">&nbsp;&nbsp;Lord_of_the_Rings</a></option>
<option value="739"><a href="http://www.bigpat.com/gifts/index.shtml">&nbsp;&nbsp;Gifts & Occasions</a></option>

Bigpat

_________________________________________________________________________________________________________________
Web directory and search engine | Dirlist.net Directory - Add your link today.

Last edited by:

Bigpat: Feb 14, 2004, 3:22 AM
Quote Reply
Re: [Andy] Global to display category dropdown... In reply to
Nice job Andy,

Is it possible to display the number of links are in each category and may be show if there are new links in it as well ?


Smile

Regards

minesite

Last edited by:

minesite: Feb 14, 2004, 7:07 AM
Quote Reply
Re: [minesite] Global to display category dropdown... In reply to
Please try the new version :)

Note the new way you have to call the template. If you don't pass ('1') then it will show the list without the number of links in it ;)

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] Global to display category dropdown... In reply to
Thanks Andy, it works well.

Great navigation tool and also gives the Webmaster a good look at how deep the Cats go as well as redundant Cats.

Thanks again.

Regards

minesite
Quote Reply
Re: [Andy] Global to display category dropdown... In reply to
Don't forget to add it to the widgets site ;)


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Global to display category dropdown... In reply to
In Reply To:
Don't forget to add it to the widgets site ;)

Already have Wink

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] Global to display category dropdown... In reply to
I've also added a modified version of this global now too;

http://www.sqlwidgets.com/...rces/Detailed/8.html

It basically lets you make a static "indented" list of your categories. I've put an example of what I mean on the above URL :)

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] Global to display category dropdown... In reply to
Hi Andy,
Is there a way to convert the list into a drop down menu
Quote Reply
Re: [Abusaki] Global to display category dropdown... In reply to
I imagine something like this:

Code:

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|</option>|. "\n";
}
$output .= "</select>\n";
return \$output;
}


That should do what you want....

- Jonathan
Quote Reply
Re: [jdgamble] Global to display category dropdown... In reply to
Thanks jdgamble,
I get the drop down box alright but it takes me to the homepage when I select a category
I would prefer it to take me to the category page when I select a category
Quote Reply
Re: [Abusaki] Global to display category dropdown... In reply to
Try;

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

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!

Last edited by:

Andy: Sep 3, 2004, 10:26 AM
Quote Reply
Re: [Andy] Global to display category dropdown... In reply to
Hi Andy,
I am getting a page cannot displayed error because it takes me to http://www.domain.comcategory/
instead of http://www.domain.com/category/
and I am losing all the uppercase letters in the category names as well in the url but they appear in the drop down menu with the upper case letters like Cat1
Cat2
Ca_Tegory3
Quote Reply
Re: [Abusaki] Global to display category dropdown... In reply to
I don't see how it can be lowercasing it... as there is no lc() call in there :|

The other problem should be fixed in my above post (it was missing 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] Global to display category dropdown... In reply to
Thanks Andy, works great
Quote Reply
Re: [Abusaki] Global to display category dropdown... In reply to
Hi Andy, Could you please help me with this post


http://www.gossamer-threads.com/...;;page=unread#unread
Quote Reply
Re: [Abusaki] Global to display category dropdown... In reply to
Yeah sorry about that, just threw that up there...

- Jonathan
Quote Reply
Re: [Andy] Global to display category dropdown... In reply to
nice mod
Quote Reply
Re: [ajiimd] Global to display category dropdown... In reply to
Hi Andy,
How do I get this global to list only the Main categories without the subcategories, i tried using FatherID instead of ID but it is still listing all the cats with subcat
Quote Reply
Re: [Abusaki] Global to display category dropdown... In reply to
Try changing;

my $sth = $db->select( ['ID','Full_Name'] ) || return $GT::SQL::error;

...to;

my $sth = $db->select( ['ID','Full_Name'], { FatherID = '0' } ) || return $GT::SQL::error;

Hope that helps.

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] Global to display category dropdown... In reply to
Hi I got this error
Unable to compile 'listofcategories': Can't modify constant item in scalar assignment at (eval 22) line 8, at EOF
Quote Reply
Re: [Abusaki] Global to display category dropdown... In reply to
FatherID => '0'
Quote Reply
Re: [afinlr] Global to display category dropdown... In reply to
Thanks Andy,
works great,
i was even able to to list the subcats seperately too
Quote Reply
Re: [Abusaki] Global to display category dropdown... In reply to
In Reply To:
Hi I got this error
Unable to compile 'listofcategories': Can't modify constant item in scalar assignment at (eval 22) line 8, at EOF

Sorry, was in a rush :( As Laura said, it should have been an => and not just = Pirate

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] Global to display category dropdown... In reply to
I am able to list the categories but I am using mod_rewrite and when I click on any of the categories in the list generated by this global it takes me to the page alright but I get for the url address

http://mydomain.com/Category/?g=Category

why the ?g in the url
Quote Reply
Re: [Abusaki] Global to display category dropdown... In reply to
Mmm... whats the exact global you are using?

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] Global to display category dropdown... In reply to
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'], { FatherID => '0' } ) || return $GT::SQL::error;
while (my ($fatherid,$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|<a href="$CFG->{build_root_url}/| . $db->as_url($safe_full) . qq|">$back</a><BR>|. "\n";
}
return \$output;
}
Quote Reply
Re: [Abusaki] Global to display category dropdown... In reply to
Mmm... can you email/PM me a URL where I can see this happening?

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] Global to display category dropdown... In reply to
The following global is to list categories with FatherID equal to 0

I want to change it so it will list categories with FatherID greater than 0









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'], { FatherID => '0' } ) || return $GT::SQL::error;
while (my ($fatherid,$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|<a href="$CFG->{build_root_url}/| . $db->as_url($safe_full) . qq|">$back</a><BR>|. "\n";
}
return \$output;
}
Quote Reply
Re: [Abusaki] Global to display category dropdown... In reply to
Change;

my $sth = $db->select( ['ID','Full_Name'], { FatherID => '0' } ) || return $GT::SQL::error;

...to;

my $sth = $db->select( ['ID','Full_Name'], GT::SQL::Condition->new('FatherID','>','0') ) || return $GT::SQL::error;

Hope that helps.

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] Global to display category dropdown... In reply to
Hello Andy,

Thank you for this very good Global.

I have a question.

I place Tag on the category page (category.html).

It would be possible to select the category in the list.

Sample :

<select name="select">
<option value="1">category1</option>
<option value="2" selected>category2</option>
<option value="3">category3</option>
</select>

For =======================

sub {
my $show_count = $_[0];
my $category;
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','Number_of_Links'] ) || return $GT::SQL::error;
my $back;
while (my ($id,$full_name,$numberoflinks) = $sth->fetchrow_array) {
my $full_name2;
my @cut = split /\//, $full_name;
for (my $i=0; $i < $#cut; $i++) {
$full_name2 .= "&nbsp;&nbsp;";
}
$full_name2 .= $cut[$#cut];
if ($show_count) {
$full_name2 .= " ($numberoflinks)";
}
$back .= "<option value=\"$id\">$full_name2</option>";
}
my $send_back = qq|<select size="1" name="catid"><option value="">------</option>$back</select>|;
return $send_back;
}

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

Thank you for your assistance.

Mick
Quote Reply
Re: [mick31] Global to display category dropdown... In reply to
Hi,

You could try changing;

Code:
$back .= "<option value=\"$id\">$full_name2</option>";

to;

Code:
my $cid =$IN->param('catid') || $IN->param('CatLinks/CategoryID') || 0;
if ($cid == $id) {
$back .= qq{<option value="$id" selected="yes">$full_name2</option>};

} else {
$back .= qq{<option value="$id">$full_name2</option>};
}

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] Global to display category dropdown... In reply to
Hello Andy,

You think that it is possible to obtain the list for a higher categories (of level 0) and all the subcategory (children) ?

For example <%global(Cat.1)%>

Thank you for your answer.

Mick
Quote Reply
Re: [mick31] Global to display category dropdown... In reply to
Sorry, not sure what your asking?

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] Global to display category dropdown... In reply to
Thank you for your answer.

I would like to use your Global to obtain the list of the subcategories for a category in particular.

Cat1
---Sub1
------Sub2


And not all categories.

Cat1
---Sub1
------Sub2
Cat2
---Sub
---Sub
------Test
------Test

And I would like to also be able to call the Global one like this: <%global(CatID)%>

That would be possible ?

Thank you
Quote Reply
Re: [mick31] Global to display category dropdown... In reply to
Hi,

Ah, ok. Can you post the whole global your currently using?

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] Global to display category dropdown... In reply to
I use this global :


Code:
sub {
my $show_count = $_[0];
my $category;
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','DirName','Number_of_Links'] ) || return $GT::SQL::error;
my $back;
while (my ($id,$full_name,$DirName,$numberoflinks) = $sth->fetchrow_array) {
my $full_name2;
my @cut = split /\//, $full_name;
for (my $i=0; $i < $#cut; $i++) {
$full_name2 .= "&nbsp;&nbsp;";
}
$full_name2 .= $cut[$#cut];
if ($show_count) {
$full_name2 .= " ($numberoflinks)";
}
$back .= "<option value=\"$CFG->{build_root_url}/$DirName/\">$full_name2</option>";
}
my $send_back = qq|<select size="1" name="goto"><option value="">------</option>$back</select>|;
return $send_back;
}


<%cats_list(1)%>
Quote Reply
Re: [mick31] Global to display category dropdown... In reply to
Hi,

Try this (untested);

Code:
sub {

my $show_count = $_[0];
my $root_id = $_[1];
my $category;
my $db = $DB->table('Category') || return $GT::SQL::error;
$db->select_options('ORDER BY Full_Name') || return $GT::SQL::error;

my $full_name = $DB->table('Category')->select( ['Full_Name'], { ID => $root_id } )->fetchrow;
my $sth = $db->select( ['ID','Full_Name','DirName','Number_of_Links'], GT::SQL::Condition->new('Full_Name','LIKE',"$full_name/%") ) || return $GT::SQL::error;

my $back;
while (my ($id,$full_name,$DirName,$numberoflinks) = $sth->fetchrow_array) {
my $full_name2;
my @cut = split /\//, $full_name;
for (my $i=0; $i < $#cut; $i++) {
$full_name2 .= "&nbsp;&nbsp;";
}
$full_name2 .= $cut[$#cut];
if ($show_count) {
$full_name2 .= " ($numberoflinks)";
}
$back .= "<option value=\"$CFG->{build_root_url}/$DirName/\">$full_name2</option>";
}

my $send_back = qq|<select size="1" name="goto"><option value="">------</option>$back</select>|;

return $send_back;
}

<%global_name(1,CAT_ID_OF_ROOT)%>

So if you wanted "Business" (ID=5) to be the start, you would use;

<%global_name(1,5)%>

Hope that helps/works =)

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] Global to display category dropdown... In reply to
Thank you Andy,

Your code is very good.

I want to send to you a contribution with PayPal.
You can give me an email ?

Mick
Quote Reply
Re: [mick31] Global to display category dropdown... In reply to
Hi,

Thanks Cool (PayPal email is paypal @ ultranerds.com Smile)

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] Global to display category dropdown... In reply to
Hello, it is a nice global indeed.

1- is it possible to let work in Dynamic Mode?

2- is it possible to let categories open in a new window (_blank) ?

waiting to hear from you
Antoine
Quote Reply
Re: [mick31] Global to display category dropdown... In reply to
Why is this not linking?

<option value="6581">&nbsp;&nbsp;Category Name (0)</option>


Sandra Roussel
Chonsa Group Design - Fresh Start Housing
Quote Reply
Re: [SandraR] Global to display category dropdown... In reply to
OOps - did not explain myself correctly... Its not linking, did anyone get it to work?

Code:
sub {
my $show_count = $_[0];
my $category;
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','Number_of_Links'] ) || return $GT::SQL::error;
my $back;
while (my ($id,$full_name,$numberoflinks) = $sth->fetchrow_array) {
my $full_name2;
my @cut = split /\//, $full_name;
for (my $i=0; $i < $#cut; $i++) {
$full_name2 .= "&nbsp;&nbsp;";
}
$full_name2 .= $cut[$#cut];
if ($show_count) {
$full_name2 .= " ($numberoflinks)";
}
$back .= "<option value=\"$id\">$full_name2</option>";
}
my $send_back = qq|<select size="1" name="catid"><option value="">------</option>$back</select>|;
return $send_back;
}


This one works perfect but does not indent the subcategories and I really do like the link count better
Code:
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>Site Categories</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;
}

Thank in advance for any comments or re-writes.


Sandra Roussel
Chonsa Group Design - Fresh Start Housing

Last edited by:

SandraR: Oct 12, 2006, 2:54 PM
Quote Reply
Re: [SandraR] Global to display category dropdown... In reply to
How about:

Code:
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', '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>Site 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;
}

Philip
------------------
Limecat is not pleased.
Quote Reply
Re: [fuzzy logic] Global to display category dropdown... In reply to
Limecat may not be pleased.

But your a Genius :D

Thank you

Philip


Sandra Roussel
Chonsa Group Design - Fresh Start Housing
Quote Reply
Re: [antoined] Global to display category dropdown... In reply to
In Reply To:
1- is it possible to let work in Dynamic Mode?

Is is possible to have it work in dynamic mode?


Sandra Roussel
Chonsa Group Design - Fresh Start Housing
Quote Reply
Re: [SandraR] Global to display category dropdown... In reply to
Code:
$output .= qq|<option value="$CFG->{db_cgi_url}/page.cgi?g=| . $db->as_url($safe_full) . qq|/$CFG->{build_index};d=1">$back ($cnt)</option>|. "\n";

Just a slight modification of the code ;-)

Philip
------------------
Limecat is not pleased.
Quote Reply
Re: [fuzzy logic] Global to display category dropdown... In reply to
Curious anomaly:

Added a few more categories, the drop down is not recognizing them.

Hey, Phillip nice to see you working like me on the weekend :D


fixed it: took out

,'LIMIT 100'


Sandra Roussel
Chonsa Group Design - Fresh Start Housing

Last edited by:

SandraR: Oct 14, 2006, 10:11 AM
Quote Reply
Re: [SandraR] Global to display category dropdown... In reply to
I changed it so it contains the number of links:
Here is a view of it in action Sitemap

Would it be possble to make it contain New or Updated?

Code:
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'] );
my $output=qq~<table width="100%"><tr valign=top><td width="50%"><table>~;
my $i=0;
while (my ($cat,$ID,$heading,$depth,$cnt) = $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 ($depth > 0){$output .= "</font>";}
else {$output.="</b>";}
$output.=qq~</td></tr>~;
if (($i eq '91')){ $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] Global to display category dropdown... In reply to
Hi,

Something like this should do the trick;

Code:
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| <sup>new</sup> |; }
if ($changed eq "Yes") { $output .= qq| <sup>changed</sup> |; }
if ($depth > 0){
$output .= "</font>";
} else {$output.="</b>";}
$output.=qq~</td></tr>~;
if (($i eq '91')){ $output.=qq~</table></td><td width="50%"><table align=top>~;}
}
$output.="</table></td></tr></table>";
return $output;
}

Hope that helps.

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!

Last edited by:

Andy: Nov 7, 2006, 4:53 PM
Quote Reply
Re: [Andy] Global to display category dropdown... In reply to
Hey Andy,

Did not work - it showed both option:

Rector-Area News Media (9) new changed


Sandra Roussel
Chonsa Group Design - Fresh Start Housing
Quote Reply
Re: [SandraR] Global to display category dropdown... In reply to
Hi,

Please try the modified version above (changes are in red)

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] Global to display category dropdown... In reply to
Worked :) Woohoo

Thanks Andy


Sandra Roussel
Chonsa Group Design - Fresh Start Housing