4

I am using a JSON plugin to Views to output taxonomy terms as a JSON object for Javascript manipulation. I was to be able to include the parent ID in this output.

In view I see "Taxonomy term: Parent term" under relationships and I have added that to the view. But under "Fields" -> "Add" there is still no "Parent term" listed in the available fields. I'm pretty sure the "pid" should be available. Is there some other way of accessing that field via the Views UI?

1
  • 2
    I don't have a taxonomy view to hand to play with, but I'm pretty sure you just want to choose tid (term ID) for your field, and select the parent term as the relationship on the settings form
    – Clive
    Nov 20, 2012 at 12:55

1 Answer 1

13

Thanks Clive! Yes - I just found the solution. I took the following steps:

  1. Under "Relationships" add "Parent term" and untick "Require relationship"
  2. Under "Fields" add "Taxonomy term: Term ID" and under that select from the "Relationship" pulldown "Parent"

Since the relationship is not required, it will correctly show both top-level terms and all children term. Top-level terms has parent ID of 0.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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