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

Global to display category dropdown...

(Page 1 of 3)
> >
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
> >