Jump to content

[Q] How can I identify the parent category?


Recommended Posts

How can I identify the parent category when browsing in category.tpl? And ultimately, the top category... besides from home ofcourse. This is for identifying which way products in the current category will be displayed.

All help is appretiated :)

Real sorry if this has an obvious solution, just came off a nightwatch and kinda both in a hurry with developing this and getting some sleep, heh. Cheers guys, keep up the good work all :)

Link to comment
Share on other sites

Hello and thanks for your response. Sorry about the vague formulation. I was about to run off somewhere, hehe.

What I mean is:

I want to use several different ways to display products (meaning the result from category.tpl & product_list.tpl), depending on what category they are in (if category == this, then show them this way, if category == that, then show em the other way. And I want to be able to define for example that all subcategories of "X" shall use mode "Y" to display products.

More concretely, I could have this kind of setup:

HOME
--- cars
---------- big cars
---------- small cars
---------- toy cars
--- houses
---------- xxx
---------- xxx
---------- xxx


....and I don't want to keep updating the ID's for big cars, small cars, toy cars. I just want to define that, "OK -- all categories under CARS will show products in a grid! and all categories under HOUSES will show products in a LIST!

Hehehe, clear? :P

Link to comment
Share on other sites

Ahaaa. So basically you want to use a different template / display style for each particular category as you have mentioned.
This will require at least some smart php programming and your main category ID's cannot change, otherwise you have to re-edit your template file again.

So in program terms you should edit your category.tpl file and like this :

IF category ID = 2 > Display like Grid
IF category ID = 3 > Display like List
etc

Link to comment
Share on other sites

Wth I'm sure I replied to this twice by now, hehehe. But yeah, correctamundo.

Thing is I'm hoping to avoid that and find some way of identifying if $category (current category you're browsing) is inside $somecategory .... and if it is, to this and that and shazam. I found out one can use $id_category_parent to find $category's parent... Meh, i'll figure it out ^^

Just came to think of breadcrumb, contains $path :] Could simple check for the ID there.

Link to comment
Share on other sites

×
×
  • Create New...