Forums / All Other Contributions/Addons / how to get the value of current category with PHP code?

how to get the value of current category with PHP code?

Started by mybiz9999 on 16 Feb 2011, 10:48 AM · Views: 1,257

Results 1 to 6 of 6
16 Feb 2011, 10:48 AM
#1
mybiz9999 avatar

mybiz9999

Zen Follower

Join Date:
Jul 2010
Posts:
143
Plugin Contributions:
0

how to get the value of current category with PHP code?

try to optimize a add-on. but I am a newbie of PHP.

how to get the value of current category with PHP code?

such as

top Category----subCate1----subCate2---subCate3: Product A

When the page of Product A displayed, how to get the value of current category with PHP code?

also how to get the value of all parent categores all the way to top category?

Thank you so much

16 Feb 2011, 11:32 AM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: how to get the value of current category with PHP code?

What is it that you are actually trying to do?

I get that you want to grab the category path for the product being displayed BUT what/why are you needing this and to do what?

Zen-Venom Get Bitten

16 Feb 2011, 12:21 PM
#3
mybiz9999 avatar

mybiz9999

Zen Follower

Join Date:
Jul 2010
Posts:
143
Plugin Contributions:
0

Re: how to get the value of current category with PHP code?

kobra:

What is it that you are actually trying to do?

I get that you want to grab the category path for the product being displayed BUT what/why are you needing this and to do what?

Thank you so much!!

Yes, that's what I want(grab the category path ).

I am making a add-on, so I need the PHP code of grabing the category path.

Please help. Thank you !

16 Feb 2011, 12:52 PM
#4
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: how to get the value of current category with PHP code?

I am making a add-on
Please expand
Where will you be when this addon is to get that info
What will the addon be expected to do with it
etc

Zen-Venom Get Bitten

16 Feb 2011, 3:28 PM
#5
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: how to get the value of current category with PHP code?

$_GET['cPath'] holds the current category path; how you break it down to use depends on what you want to do with it, as kobra said. And of course it doesn't exist if you are not in a product/category page, so you may need to take that possibility into account in your code.

16 Feb 2011, 4:27 PM
#6
mybiz9999 avatar

mybiz9999

Zen Follower

Join Date:
Jul 2010
Posts:
143
Plugin Contributions:
0

Re: how to get the value of current category with PHP code?

Thank you so much, gjh42!