I am really bad at explaining things so I will just use images to best illustrate what I am trying to do.

To summarize, I am learning Drupal 8 and I thought my pet project would be to create a grocery list application. In simple terms, you add ingredients with there cost, quantity, and store, ect. From there, you combine the ingredients to create a meal. Finally, you select all the meals you want to buy for the week, and it will generate a grocery list with all the ingredients, with cost and quantity.

The issue i'm running into with views is that I can only go 1 level deep down the hierarchy chain. Let me demonstrate with pictures.

Here is my grocery list:

enter image description here

Next, I can dive into 1 of the meals, ex: Salad.

enter image description here

From there, I can dive even deeper and view the cost or quanity of a ingredient, ex: cheese.

enter image description here

Now what I am trying to achieve with my view is getting the cost or quantity (either is preferable at this point), to display. However, I can only go down to meal ingredients and it stops there.

I am already using a relationship to display the meal_ingredients, but there is no option or relationship to reference ingredients. If I change the filter to CT = meal or ingredient, the cost value is displayed, but on other lines.

How do I dive 1 step further and get my table to display the cost / quanity without changing the filter? Can views go only 1 level deep?

enter image description here

  • By concept views creates flat lists, not hierarchies. So yes, views can only go 1 level deep. In theory, you can "simulate" depth by grouping/aggregating, but this only works for simple use cases. – Hudri Mar 19 '19 at 13:28
  • 1
    I think I finally found a solution, which was I needed to tie the relationships together. You can add a 'relationship' to a relationship. This created a hierarchy for me. – Shawn Mar 19 '19 at 14:09
  • There is no info about your Relationships in your screenshots but yes, you can chain Relationships to continue adding related information to the Views. – prkos Mar 19 '19 at 17:58

Your Answer

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

Browse other questions tagged or ask your own question.