0

I am using Views and Drupal Commerce but not sure this should matter as all my products are also nodes. I have a taxonomy hierarchy for categories. Example

Exterior Accessories
|_ Top
   |_ Soft Tops
   |_ Hard Tops
|_ Bottoms
   |_ Right Bottoms
   |_ Left Bottoms

I can easily make a page that shows me the Hard Tops if on that location or Soft Tops if at that location. But is what i can not for the life of me figure out how to do is if I click on TOP I want to see Soft Tops and Hard Tops, and if I click on Exterior Accessories I want it to show products that are from any of the child elements with unlimited depth. So when viewing one of these pages it needs to work like so with the url.

categories/Tops -> Would show soft tops and bottom tops categories/Soft-Tops -> would show soft tops only categories/External-Accessories -> Should show everything

  • Welcome to Drupal Answers! Did you use views as tag because the question is about the Views module? If that is the case, make it clear in the question in what way you are using the Views module. Otherwise, if you added views because the question is about displaying nodes, you are using the wrong tag. – kiamlaluno Jul 11 '16 at 7:16
  • This has originally been tagged with views. – Atrium Jul 11 '16 at 15:16
  • Yes, but there was no reference to the Views module in the question body; that is why I asked. – kiamlaluno Jul 11 '16 at 15:33
0

There is a function called taxonomy_get_tree() that you can use to fetch all the term IDs under a given parent ID. You can then call taxonomy_select_nodes() with an array of term IDs, which will return all nids that match that collection of tids.

  • I was hoping there would be an answer that could be done by actually using views. However, I am running out of time and if I can't seem to find anyone that knows how to do this, I might have to use your suggestion and just build a custom module to do it. – Atrium Jul 12 '16 at 15:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.