View to display a master and the first child?

Events happening in the community are now at Drupal community events on www.drupal.org.
Posted by kirilius on January 28, 2009 at 4:45am

I have two node types - A and B. B has a nodereference to A, thus one A (parent) has many B children:
A1
|-B11
|-B12
|-B13
...

A2
|-B21
|-B22
|-B23
...

I need a view that displays a row per A-node along with one of A's children (the first, a random, etc.). Example:


A1 B11


A2 B21


A3 B31


I saw a podcast showing how to do the reverse: for each child, use the Views relationships to show the parent's title for example. That's clear but I need it top-down: for each parent show one child. How can I do this with views?

Comments

OK this is an ancient post,

Posted by scottprive on January 16, 2010 at 4:15am

OK this is an ancient post, but I'll reply anyways in hopes that we can help each other out.
I have the same problem to solve. In adding Views2 to the Recipe module, I come across this problem:

1) each recipe has a variety of things specific to that NID and which occur in tables once.
Examples: Instructions, prep time, credit/source, serving sizes.

2) Each recipe NID has > 1 ingredient. These are stored in another table, referenced by NID.
(A good reason for this is to avoid duplicate ingredients, being able to maybe use taxonomy, etc.)

Anyways, if I create Views which include ingredients, I get this:

ingredient1, Instructions, preptime, credit, servings
ingredient2, Instructions, preptime, credit, servings

Now your problem sounds identical in nature..

I spoke to Earl (Merlin), and he had some great advice:th
Write a field handler. He said " You're creating a specific field that is functionally very similar to Taxonomy: All Terms or Node: Attached Files ".
Basically the field handler will do a select on all of the "many" children, and return the data set (set of ingredients).
A views handler can basically invent data, or include non-database data.

Now I've looked at the above referenced code a little, and I'm still in over my head. I haven't found a blog posting or tutorial on this sort of thing.
Obviously, it can be done... so I'm plugging away at it here and there.
Hope this helps you get things moving..

views-relationship 1 to many

Posted by aishaobrien on October 7, 2010 at 10:54am

Hi,

I am wondering if you found a solution - i am having the exact same problem - i need one "receipe" to show several "ingredients".

hi, Amy update On this

Posted by summit on February 3, 2011 at 7:56am

hi,
Amy update On this please. having same need.
Thanks à lot in advance!
Greetings,
Martijn

Views Developers

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

AltStyle によって変換されたページ (->オリジナル) /