Hello,
I am using the views module to show a users data in the table format. My issue is there are three different data types involved that need to be combined.
Data types:
Vocabulary:
Meal Time: Breakfast, lunch, Dinner
Content Type:
Foods: Name, Protein, sugars, Carbs, Calories
Content Type:
Users Foods: Meal time ID, Food ID
For each User foods entry I wish to display a singular row for each item, grouped by meal time:
Group: Breakfast
Food name | Protein | Carbs | Calories
Group: Lunch
Food name | Protein | Carbs | Calories
Group: Dinner
Food name | Protein | Carbs | Calories
I have been able to achieve variations of this ie:
- Grouping by meal time which only returns food name using an entity reference.
- Food name and nutritional data, but no grouping by meal times.
If I have foods and users foods in the content filter, it will return all the rows individually.
I know how to achieve this by creating a module and going that route, but I would like to use views and the paging features if possible.
thanks,
Nick
Comments
Create a view of content type
Create a view of content type 'foods' unordered display.
Now Click on +ADD and add an attachment
Repeat the process for 'Dinner'
Add titles to each attachment using the 'header' fields
Remember to override the sections.
Hope that helps
Mike
This is an interesting
This is an interesting approach, however I can not get it to work as needed.
I need to display only the foods entered by the user via a form that collects
Food ID and Meal Time ID.
Then when building the view I need to show all the info related to the Food ID that the user has submitted by the form, grouped by the Meal time.
User Meals, Foods and now Meal Times are all content types.
Might be worth mentioning that Foods are predefined and selected from a list along with meal times. They are linked to User foods by their node ids.
thanks,
Nick
I figured it out, thanks for
I figured it out, thanks for your help!
I had to use relationships in the view module.
Here's what I did:
I set the users_food content type as the views content type filter. Then I added a relationship "Entity Reference: A bridge to the Content entity that is referenced via field_foods_id" as well as "Entity Reference: A bridge to the Content entity that is referenced via field_meal_time_id."
Then when adding fields to the view/page there is a relationship drop down available to choose which relationship to get field value from. I created a label for the column and clicked save.
thanks again for your time!