View Full Version : Get Current Category Name
b2pix
Jun-10-2009, 04:31 PM
I've searched and searched and can't find anything helpful.. just lots of way more complicated than what I'm trying to do..
I need to get whatever the current category name is for the current gallery page.
For instance, if I'm on this page:
http://jti.smugmug.com/gallery/8113366_ifEZV#528927906_cTAk5
I want a variable or function call that would return "Landscapes" as the current category.
Anybody got something simple for that?
(I'm talking javascript here, btw)
chrisjlee
Jun-10-2009, 09:25 PM
Since i'm not logged in to your gallery as an authorized administrator i cannot see where the gallery is going.
@chrisjlee
jfriend
Jun-10-2009, 09:41 PM
I've searched and searched and can't find anything helpful.. just lots of way more complicated than what I'm trying to do..
I need to get whatever the current category name is for the current gallery page.
For instance, if I'm on this page:
http://jti.smugmug.com/gallery/8113366_ifEZV#528927906_cTAk5
I want a variable or function call that would return "Landscapes" as the current category.
Anybody got something simple for that?
(I'm talking javascript here, btw) I've not seen anything that gives you the category easily from Javascript. When I've needed either the category name or URL, I've had to parse it out of the breadcrumb.
b2pix
Jun-11-2009, 10:43 AM
I've not seen anything that gives you the category easily from Javascript. When I've needed either the category name or URL, I've had to parse it out of the breadcrumb.
Great. That's helpful. But please talk to me like I have no clue what you are talking about (cuz I don't)
jfriend
Jun-11-2009, 12:12 PM
Great. That's helpful. But please talk to me like I have no clue what you are talking about (cuz I don't) Can you back up a step and describe overall what you're trying to accomplish?
b2pix
Jun-11-2009, 04:27 PM
Can you back up a step and describe overall what you're trying to accomplish?
I am adopting the PayPal cart code to my pages.. but I do NOT want it to show for certain categories, and ultimately, I would like to have different products offered for different categories.
jfriend
Jun-11-2009, 05:47 PM
I am adopting the PayPal cart code to my pages.. but I do NOT want it to show for certain categories, and ultimately, I would like to have different products offered for different categories. OK, that's a lot easier. You can detect any category with this type of code:
// see if we're in the People category
if (YD.hasClass(document.body, "category_People"))
{
// put code here for the people category
}
// or for the opposite sense
// see if we're NOT in the People category
if (!YD.hasClass(document.body, "category_People"))
{
// put code here for all categories except people
}
b2pix
Jun-11-2009, 06:35 PM
OK, that's a lot easier. You can detect any category with this type of code:
Cool.. and will that work for custom categories, too?
(I know I could just try it, but thought maybe someone searching this topic in the future would like to see the answer.)
jfriend
Jun-11-2009, 06:37 PM
Cool.. and will that work for custom categories, too?
(I know I could just try it, but thought maybe someone searching this topic in the future would like to see the answer.) Yes, any category. If you have any special characters in your category name (like spaces or punctuation chars), they will get converted to something else (often underscores). You can always just do a View/Source in the browser on your category page and look at the body tag to see what the exact category class is for a custom category.
b2pix
Jun-11-2009, 06:42 PM
Yes, any category. If you have any special characters in your category name (like spaces or punctuation chars), they will get converted to something else (often underscores). You can always just do a View/Source in the browser on your category page and look at the body tag to see what the exact category class is for a custom category.
Yes, thank you.. I just confirmed that. (For instance, I have a category "Air Hogs" for all shots from a local minor league baseball team.. it is "Air_Hogs" as a category.)
Thanks for all the help. I appreciate it! :clap:barb:bow
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.