Jump to content

[SOLVED] Get Category Parent


Recommended Posts





How do I get the parent(s) of a category in blocklayered.php?


The reason I ask is that I no matter what sub-category a user chooses from a sub-menu, I always want to display from the parent category downwards. for example:


Parent-Category 1

- Sub-Category 1

- Sub-Sub-Category 1

- Sub-Sub-Category 2

- Sub-Sub-Category 3

- Sub-Category 2

- Sub-Sub-Category 2-1

- Sub-Sub-Category 2-2

- Sub-Sub-Category 2-3

- Sub-Category 3


By default, if I choose Sub-Category 1 the layered navigation block would only show the 3 sub-categories underneath, whereas I would like to show everything. In other words, no matter what sub-category I choose, every sub-category under the parent is shown.


My thinking is that if I can get the parent or grandparent of the sub-category, then I should be able to achieve this. Is this possible with this approach?


Thanks for reading.

Edited by prestatent (see edit history)

Share this post

Link to post
Share on other sites



I tried this fix but did not work. The amendment had to be included in blocklayered.php. I created a function to get the parent of the category and return the parent/grandparent of the selected category. This does now seem to work.



Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More