This is best explained with just the use case. Also, I'm not sure if this is the right place, or if views is the right place, or another forum altogether is the right place to put in this support request.
Let's say I have a content type Instructor that has basic information about the instructor that's teaching a class. Let's also say I have a content type Class Sections, which has, along with other data, an unlimited, multiple-values-allowed nodereference field for Instructors that are teaching that specific section. For example's sake, let's have the section have 2 instructors, Jim and Bob. Now, my ideal output would be:
Section 1 - M 4-5 -100 Willy Wonka Hall
Jim - [Data from Jim's Instructor Node, such as his previous experience]
Bob - [Data from Bob's Instructor Node, such as his previous experience]
Now, you'd think with the new Views relationships, this would be easy, right? Nope. The second I put in the relationship "Content: nodereference Instructors," I get this output.
Section 1 - M 4-5 -100 Willy Wonka Hall
Jim - [Data from Jim's Instructor Node, such as his previous experience]
Section 1 - M 4-5 -100 Willy Wonka Hall
Bob - [Data from Bob's Instructor Node, such as his previous experience]
In other words, for every value in the multiple-value field, views (rc1) will duplicate the node and put in only one value per duplicate. Is there a way to utilize Views relationships with multiple value cck fields to produce the output that I need?
If it's not possible, what would be an alternate way to achieve the correct output?
Comments
Comment #1
yched commentedTrue, that's the current behaviour. Perfectly normal given how relationships affect the SQL query.
It is a known general fact that SQL doesn't handle the notion of 'multiple values' too well.
Recently on IRC, merlinofchaos suggested that we restrict relationships to the first value (i.e, only relate to the 1st referenced node).
Another possibility (that I haven't actually looked into) would be to override the SQL bit that gets generated when dealing with references from a multiple values field, and write our own instead - like we currently do for the 'group multiple values' field option.
Not sure Views2 API allows that, though.
Comment #2
carnive commentedOk. Good to know that there wasn't some hidden option that I was missing.
So, what should I do to fix this? I don't have the expertise needed to muck up the SQL query (or maybe I do, if you think it isn't too hard to learn). I was thinking of maybe using nodequeue with viewfield when viewfield comes out for drupal 6, but that seems to be a rather inelegant solution, where I'd have to create a separate nodequeue for each section.
I can't be the only person that has encountered this dilemma. If there's an elegant solution in the works, I'll just create a static page placeholder for the sections and wait. But I don't know if there's anything that's coming up that I should wait for.
Comment #3
dopry commentedNo solution in the works.. This may just be one of those times when you need to write your own query.
Comment #4
scottrigbyHi carnive - did you find a solution to this? I'm experiencing the same issue with Views rc7. Or maybe there's been another resource available on this issue since July? I've run into this a bunch of times, even without nodereference - but just using a field with multiple values...
In my example, I have a single node-type, with fields A & B. Each of these is a multi-value field, so there would be A1, A2, A3 ... and B1, B2, B3.
if I choose to group the multiple values, then all the values from one field are grouped together, like:
A1
A2
A3
B1
B2
B3
But what i'd like is a sequence, like:
A1
B1
A2
B2
A3
B3
And I can't seem to sort out how to do this with views. I'm hoping this is related to this issue? Now I'm not totally sure, but that's maybe because I'm not all that familiar with how Views queries work.
Thanks in advance for your advice :)
Scott
Comment #5
steinmb commentedGetting old and is more a won't-fix thingy, so close? It is anyway a views/SQL -related issue as far as I know. Have a look at #916978: Node Reference Relationship causes duplicate fields. .
Comment #6
yched commentedYup, let's close this