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

Global to display category dropdown...

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