Hi,
I have found a problem using Views 2 to make a "simple table" (but I'm not sure this is really a bug... so I ask only "support").
The idea is this: I have two kind of users, teachers and students. Students have a custom content_profile associated (students_t), and teachers also (teachers_t). In students_t node type I have defined a user_reference where I can set the "link" between a student and is tutor (teacher). What I can obtain form the view is a table where on each row I find first name and last name of a student (and also other infos coming from his student_t) and first name and last name of his tutor. The problem his here: first name and last name are two cck fields (text) and the same two fields are used either on student_t and teacher_t (so I defined only two fields, not four!). For this reason every time I try to print on the view the first name or last name of the teacher/tutor, I see instead first name or last name of the student.
For example:
- student John Green --> tutor: Mark Brown
The wanted table is:
Student First name Student Last name Tutor First name Tutor Last name
John Green Mark Brown
The obtained table is always:
Student First name Student Last name Tutor First name Tutor Last name
John Green John Green
Is this normal? And if yes, the only way to resolve this is to define separate fields for every content_profile? (i.e student_first_name, student_last_name, tutor_first_name, tutor_last_name)
Thanks to anyone can help me.
Regards,
Saxx
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | tutoring2.png | 11.64 KB | SaxxIng |
| #5 | tutoring.png | 12.73 KB | SaxxIng |
Comments
Comment #1
merlinofchaos commentedThe problem appears to be that you are implying that selecting fields from one type will automatically link in related types and make their fields available. While these fields are available, this linkage is not automatic.
What you need to do is create a relationship on your user reference, and use that relationship when selecting fields. Now, I'm not quite sure what you're using to get from a user to a node, presumably content_profile or something, so you may need to invoke two relationships, one to get from node --> user and then one to get from user --> profile node.
Comment #2
SaxxIng commentedThanks a lot for the quickly reply MerlinOfChaos,
but this is exactly what I'm doing. In fact all works correctly if I view a field of teacher_t other of first_name or last_name (i.e. a field that isn't present also in student_t).
The problem arises only if I try to view a field that is present identically in student_t and teacher_t.
I have tried a lot of views customizations to resolve the problem, but without results.
The last (the one permits me to see correctly other fields of teacher_t, but first_name and last_name) doing this:
The view is built on users. I did a relationship with custom_profile of type student_t (named student). On this I build a relationship with user_reference (named tutor). On this I build a relationship with custom_profile of type teacher_t (named teacher). With this view I can do the the above:
For example:
- student John Green class 1st --> tutor: Mark Brown matter Math
The wanted table is:
Student First name Student Last name Student Class Tutor First name Tutor Last name Tutor Matter
John Green 1st Mark Brown Math
The obtained table is always:
Student First name Student Last name Student Class Tutor First name Tutor Last name Tutor Matter
John Green 1st John Green Math
So the problem regards only fields with the same name on on the two type of nodes student_t and teacher_t (instead the two fields "student_class" and "teacher_matter" didn't create any problem and working correctly).
Thanks a lot!
Regards,
Saxx
Comment #3
merlinofchaos commentedCan you try the -dev version? This is something that may already be fixed.
Comment #4
SaxxIng commentedHi,
I have tested the last dev version but the problem is not solved.
I'll try to recreate the problem with a fresh minimal installation and eventually I'll post more informations about this.
Thanks a lot.
Saxx
Comment #5
SaxxIng commentedHi merlin,
I have recreated the problem on a fresh minimal installation (drupal 6.9, cck 2.1, content_profile 1.0-beta3, views 2.x-dev).
The configuration are the same presented before:
- one content type student_t (content_profile) with fields field_first_name, field_last_name, field_class, field_tutor (user reference)
- one content type teacher_t (content_profile) with fields field_first_name, field_last_name, field_matter
I have populated the db with four users, two students (Martha White and Charles Black) and two teachers (John Green and Mark Brown).
I have created the view as described in previous post (and coherent with your suggestions) and the result is the same previously cited.
I attach the screenshot of the table resulting and I post above the query and the exported view.
QUERY
EXPORTED VIEW
Thanks a lot for your attention. If you need some other information or tests, tell me.
Best regards,
Saxx
Comment #6
merlinofchaos commentedOk, the presence of content_profile is kind of an ugly wildcard for me. I wonder if we can reproduce this with just CCK? Maybe just through nodereferences? That might teach us something too.
Comment #7
SaxxIng commentedHi merlin,
I have tried to define two new node types: s_t (type for student with first_name, last_name, class and a node_reference to a t_t type) and t_t (type for teacher with first_name, last_name and matter).
I have populated four nodes with the same values of the previous post (two student and two teachers) and I have created a new view (based on nodes) with "the same logic" of the previous (but this time I need obviously only one relationship, based on nodereference).
This is the query:
QUERY
and this is the exported view:
EXPORTED VIEW
Unfortunately the result is the same! If you use the same field on each node type (s_t and t_t) the result (regarding this fields) are wrong. I attach also the image of the resulting table (identically to the previous one).
This test at least confirm us that this isn't a content_profile problem/bug.
If you have some other tests to do, tell me.
Thank you!
Best regards,
Saxx
Comment #8
SaxxIng commentedHi,
I have done some other tests, with other fields types and other views (with the same logic behind), but the result is still the same.
I think at this this problem can be targeted as a views bug, because the case of using the same field on different node types isn't so unusual (the cck interface is heavily projected to do this).
If you need some help on testing, tell me.
Thanks a lot.
Best regards,
Saxx
Comment #9
merlinofchaos commentedI think you've got me some pretty good information. It will take me some time to dig into this; this won't be a quick investigation, I suspect, and I'm pretty busy, but will figure this out. Thanks!
Comment #10
SaxxIng commentedThanks to you for the great work and this wonderful module!
As obviously, if you need some help (testing versions/patches) regarding this problem, tell me.
Best regards,
Saxx
Comment #11
jlevy commentedHello,
I am also experiencing this problem, and just wanted to add another piece of information. I am also working on a system for tracking tutoring activity. The view is for tutor requests, which have a tutee, and a course instructor. I am pulling the name from the Content Profile of each. Each link requires two relationships (first the userreference field to the user, then Content Profile to get to the node), for a total of four relationships.
Whichever field is ordered first is the one whose value gets displayed for BOTH fields. For example:
Tutee Name | Instructor Name
Joe Tutee | Joe Tutee
And if the order is reversed:
Instructor Name | Tutee Name
Dr. Mary Faculty | Dr. Mary Faculty
No changes are made besides reordering the fields. Please let me know if I can be helpful in finding a solution.
Thanks,
Jeff
Comment #12
merlinofchaos commentedI haven't looked into this deeply enough to know, but does this patch http://drupal.org/node/386986 affect this issue?
Comment #13
SaxxIng commentedWell, I have installed the last dev release (2009/03/26) on my test drupal installation (quite fresh), but the problem persists.
If you need some deeper test, tell me.
Thanks a lot!
Regards,
Saxx
Comment #14
merlinofchaos commentedDoes quicksketch's patch in http://drupal.org/node/317271#comment-1459264 fix this issue?
Comment #15
SaxxIng commentedWell, today I have no time to test it sufficiently. I have applied this patch on my local test site and the results are:
- the view with the use of content_type doesn't work well (fields of teacher_type are empty)
- the view with the use of only users works well (results are correct).
On the next days I'll test it more.
Thanks a lot,
Saxx
Comment #16
SaxxIng commentedWell, I've tested this more.
I can confirm that for simple view (like post #7) this patch works well.
Instead for a more complicated view (like the original in post #5) the patch doesn't work. Really I think the problem is strictly related to the one I have posted on #433290: Fatal SQL errors caused by broken table aliases in some cases in add_relationships(). In this view in fact the problem is that the query is constructed bad and the table name in some joins are empty. I'm confidently that resolving the issue #433290: Fatal SQL errors caused by broken table aliases in some cases in add_relationships() can resolve indirectly also this problem.
As always, I'll test it more if you need it.
Thanks a lot and best regards,
Saxx
Comment #17
jlevy commented@merlinofchaos - Yes, quicksketch's patch solves my problem (see #11). Thanks!
Jeff
Comment #18
SaxxIng commentedHi,
I have tested last views version (2.5) with the suggested patch more deeply, using the last Content profile version (dev).
The view doesn't work correctly, but I've discovered the problem on the query. Above is the executed query (created by the views module):
and above is the query modified "by hand" and tested on phpmyadmin:
The difference is in line 16 where I have changed:
users.uid = node_users_1.uidto:
users_node_data_field_tutor.uid = node_users_1.uidThis last query gives the correct result, where instead the first gives the wrong result.
Unfortunately I don't know where to watch (in the incredible views module code) to find the "code bug" and work to a patch. As always I can do all the tests you need to help you on this problem.
Thanks a lot and best regards,
Saxx
Comment #19
dawehnerThen you have to select the relationship too, for this filter, by student.
Comment #20
SaxxIng commentedProblem fixed with latests views releases.