0

I have a parent content type which is categorized with a taxonomy term. Then there are child nodes to the parent. When someone clicks on a category, I want them to see a table basically. It would be of the form:

Parent1 Description

Child1 Description

Child2 Description

Parent2 etc

Seems out of the box I can't get Views to behave that way, so I was thinking I would have one view that is for the Parents, and another for children of a parent, and then somehow (via Display Suite for instance) have the page display the views one after another. Though I suspect that way of thinking is counter to what drupal is all about, so I am really trying to harnass the power of drupal to make that happen, as opposed to writing a custom module (though in the end I think such a custom module would be easier than Views, but I want to max out my understanding of Views before I go that route).

That said, how would you go about creating the Views and then controlling the display in Display Suite?

EDIT: So I figured out the SQL query that would return the results how I want them. Basically something like this

SELECT n.title, d.field_description_value, n.nid, l.field_lesson_target_id from drupal_node n

JOIN drupal_field_data_field_description AS d ON d.entity_id = n.nid

JOIN drupal_taxonomy_index AS t ON t.nid = n.nid

LEFT JOIN drupal_field_data_field_lesson AS l ON l.entity_id = n.nid

ORDER BY COALESCE(l.field_lesson_target_id, n.nid), l.field_lesson_target_id, n.nid

I made sqlfiddle

So I guess it comes down to whether Views is able to produce such queries.

8
  • How you got parent and child nodes connected together? Entity reference or something like that?
    – leymannx
    Sep 28 '15 at 20:18
  • Yes, Entity Reference field links them Sep 28 '15 at 20:49
  • 2
    @BrianHuether I would recommend adding a relationship and then the necessary titles (first title field would be parent, second tie to the relationship). Then you can group by the title (of the parent). Sep 28 '15 at 21:42
  • @AlexLaughnan I agree with your solution. OP can in addition override a views theme template for the grouping. Using tables means Views will use fields which rules DS pretty much out. Sep 29 '15 at 4:02
  • The only relationship that will be available to select is taxonomy term. Which results in Views viewing both parent and child equally. Or I might be missing some deeper nuance about Views... Sep 29 '15 at 16:39
0

Per the creator, the answer is in the comments with some additional documentation here: http://drupaleasy.com/blogs/ultimike/2009/02/displaying-hierarchical-content

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.