Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Node References on D7 are not working for relationships. They are not even showing up as relationships. This patch attempts to add that back in.
Comment | File | Size | Author |
---|---|---|---|
#63 | references_relationship_handler-962694.patch | 5.63 KB | yched |
#42 | references_relationships-962694-42.patch | 2.66 KB | yched |
#25 | references-add-base-field-962694-25.patch | 1.63 KB | das-peter |
#20 | references_962694.patch | 1.6 KB | fgm |
#17 | node_ref_views_3_d7.patch | 1.46 KB | dawehner |
Comments
Comment #1
dawehnerLooks fine
Comment #2
das-peter CreditAttribution: das-peter commentedSame here, works like a charm - thanks.
Comment #3
aiwata55 CreditAttribution: aiwata55 commentedThe patch works fine.
Thank you so much!
My environment:
- Drupal 7 beta 1
- Views 7.x-3.x-dev (2010-Oct-19)
Comment #4
dawehnerMove module
Comment #5
fgmupdating issue for References module.
Comment #6
mattis CreditAttribution: mattis commentedworks fine here
Comment #7
jcarlson34 CreditAttribution: jcarlson34 commentedWorks great here too. It's great to have this functionality back.
Works with the currently available downloads:
- Drupal 7 RC 1
- Views 7.x-3.x-dev (2010-Dec-4)
One caveat: The relationship did not appear until I cleared the Views' cache. Just in case anyone tried the patch and didn't see relationship, that is most likely the reason why.
Comment #8
fgmMaybe this means the patch should include a hook_udate to clear cache ?
Comment #9
jcarlson34 CreditAttribution: jcarlson34 commentedTough to say... with only ~50 sites reporting usage at this time, I think it is safe to add it in without the hook.
Comment #10
fgmCategorizing.
Comment #11
jcarlson34 CreditAttribution: jcarlson34 commentedJust to follow up, I've been using this module extensively in the last few days while building views. No problems other than that initial views cache snag that I can see.
Should we RBTC this?
Comment #12
BenK CreditAttribution: BenK commentedSubscribing
Comment #13
dawehnerAs long you didn't changed the module name there is no reason why this shouldn't work anymore.
Comment #14
yched CreditAttribution: yched commentedOops, missed that one so far. Thanks mfer !
No time to look at this tonight, but I'll give it a try - or @fgm, if you beat me to it :-)
Comment #15
yched CreditAttribution: yched commentedIdeally, we'd need the same for user_reference.
Comment #16
gorillaz.f CreditAttribution: gorillaz.f commentedsame with #15
Comment #17
dawehnerHere is a rerole
Comment #18
fgmAs I see it, commenting is a bit misleading:
node_reference_field_views_data()
is not an implementation ofhook_views_data()
: that role is fulfilled byfield_views_data()
, which in turn takes its data from implementations ofhook_field_views_data()
likenode_reference_field_views_data()
and implementations ofhook_field_views_data_alter()
, of which there is currently none in Views 3.Another issue: on the one hand, having this function use
field_views_field_default_views_data()
means the module becomes dependent onfield.views.inc
, but it does not make sure that file is loaded. On the other hand, as an implementation of a hook defined in that same file, it will only ever be invoked if the module to which that file belongs is actually enabled, meaning the dependency will always be fulfilled unless some other module invokes that hook too, which I guess should not happen. I wonder what is the Drupal policy on such situations: should the dependency be recorded in the info file in some way ?Comment #19
johnvI applied patch #17, and it works fine. I use D7-rc3 and Views 7.x-3.x-dev (24-dec-2010).
Comment #20
fgmComments updated
Comment #21
gorillaz.f CreditAttribution: gorillaz.f commentedWhen I applied patch in #20, my test site went to white screen.
I'm using drupal core dev (dec-24) + views dev (dec-26) + references dev (dec-07).
Comment #22
jcarlson34 CreditAttribution: jcarlson34 commentedSince around the 28th, I also just started having a white screen appear on every views edit screen that included a field reference. The white screen appears with all patches here: #0, #17 and #20.
Upon trying to add a reference to a new view, the follow error message appears:
Coincidentally whatever happened does not affect the output on views that already have a field reference. Those views display the correct referenced information.
I'm using the D7 RC4 / Views dev (Jan-1) / References dev (Dec-07)
Comment #23
jcarlson34 CreditAttribution: jcarlson34 commentedAn update to my last post in #22...
With the latest build of Views, the white screen no longer appears and I can edit my view again. So whatever was a problem must have been with some of the views dev releases and not with this patch. Sorry for the false alarm!
Comment #24
fgmjcarlson, thx for the heads up. I was really wondering what could have gone amiss.
Comment #25
das-peter CreditAttribution: das-peter commentedAdded
base field
definition since I got a notice under some circumstances. Unfortunately I wasn't able to exactly define the conditions to trigger the issue.Notice was thrown in
views/modules/field/views_handler_field_field.inc
line 57.The code "causing" this notice was introduced by #1002744: Use entity_load for fieldapi field handlers.
Btw. besides this everything seems to work -> RTBC?.
Comment #26
johnvPeter,
I tested and used patch #17 on D7-rc3 and Views from around 25 december, and it worked fine. SO for me #17 was RTBC.
Today I upgraded to today's (7jan2010) -dev of Views, and got the same error (I think, I include the complete error below).
So, I have installed patch #25.
However, every view using node_reference, now gives empty fields!
My views-dev-version includes issue #102744.
I am still on D7RC3, could that be the problem?
This is the complete error message:
Notice: Undefined index: base field in views_handler_field_field->query() (line 57 of ...\modules\field\views_handler_field_field.inc).
Status messageDebug:
'Exception: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \'AS node_, \'node\' AS field_data_field_site_ref_node_entity_type, \'node\' AS field_\' at line 1' in views_plugin_query_default->execute() (line 1314 of C:\Damp\Sites\drupal-7.0-rc3\sites\all\modules\views\plugins\views_plugin_query_default.inc).
Comment #27
Dave Reid#25 has worked great for us at Palantir with the latest D7.0.
Comment #28
das-peter CreditAttribution: das-peter commentedjohnv,
If you're using the latest views dev there's no need to patch it with #1002744: Use entity_load for fieldapi field handlers - this patch was integrated on the 5 / 6th January.
And atm. I can't imagine that using D7RC3 causes this problem.
Only things I can imagine are these:
node_reference/node_reference.module
for'base field' => 'nid',
. If you find it it's ok.Could you check these two possibilities?
Comment #29
jcarlson34 CreditAttribution: jcarlson34 commentedFor what it's worth... my latest experience with these patches and views:
#17 and Views Jan 7 (with the views patch in #1002744) did not fix the #26 error for me (with clearing the cache).
#20#25 and Views Jan 7 worked after I cleared the Views cache but not before.Hats off to everyone for getting this great feature RTBC.
Comment #30
johnvjcarlson34,
in you latest comment #29, you say:
>> #20 and Views Jan 7 worked after I cleared the Views cache but not before.
Do you mean #25 ? Because #17 and #20 are the same, apart from comments.
Comment #31
johnvPeter,
Perhaps I must redefine my issue better:
The reference works, and I can show the ref'd node-title and even the 'rendered node' of the node-reference.
But if I add a field of the referenced node, this data does not get fetched. Or, if both content types contain the same field, the field-value is shown of the main-node, not of the referenced node.
Perhaps I made an error, please check below data.
Modules: D7.0 (5-jan-2011) + Views-dev (7-jan-2011) + References-dev (25-dec-2010)
Patches applied to node_reference.module: 962694#25 + 993394#5 + 1005364#4
Patches NOT applied to node_reference.module: 945004#10
Content Types: V (viewed) and R (referenced). Content type V has a node_reference-field 'R_ref' to R.
View-Relationships = Fields: field_R_ref - nid (no relationship)
View-Filter = Node: Type = V
View-Fields = Fields: field_r_ref field_r_ref (title) <== OK, Title is shown,
View-Fields = Fields: field_r_ref field_r_ref (rendered node) <== OK, complete node is shown in cell.
View-Fields = Fields: field_country field_text <== OK, node's field
View-Fields = (nid) Fields: field_country field_text. <== error, node's own field is shown, not referenced node.
Sorry if this turns out in a support request...
Comment #32
jcarlson34 CreditAttribution: jcarlson34 commented@johnv ah that's what I get for posting right after I get up. Yes I meant #25. Sorry about that.
I'll edit my post above to be correct.
Comment #33
johnvUpdate on #31: I was doubting is it might be a Views-issue, so I made the same query with D6.20 + Views2 and with D6.20 + Views3. In both cases the resulted query is OK.
Comment #34
das-peter CreditAttribution: das-peter commented@johnv,
I've spent now some time trying to reproduce your issue.
My test view contains two relations based on node reference fields.
For each the base and the referenced contents I fetch at least 3 fields:
the node title (node), the node body (field) and another random field of the node type.
This means I've a "field" independent content (the node title), a "shared field" content (body) and the a node-type specific field content (random).
"Unfortunately" all this works perfectly.
I've definitely no idea what could cause the issue :|
Comment #35
johnv@Peter, I have re-implemented some of the patches. Now it works fine, --> RTBC.
Thanks for your help, sorry for the inconvenience.
Comment #37
recrit CreditAttribution: recrit commented#25 worked for us also.
D7.0
references 7.x-2.x-dev
views 7.x-3.x-dev
Comment #38
mshaw CreditAttribution: mshaw commentedThanks for this patch, I was wondering why I wasn't seeing the node reference come up and I was starting to get a little worried :).
Worked for me with the same specs as the poster above me.
Comment #39
aidanlis CreditAttribution: aidanlis commentedSub
Comment #40
fgm#25: references-add-base-field-962694-25.patch queued for re-testing.
Comment #41
kbond CreditAttribution: kbond commentedsubscribe
Comment #42
yched CreditAttribution: yched commentedTested, tweaked a bit, and committed the attached patch.
Differences with #25:
- adds the relationship on both the 'current' and 'revision' field data tables, so that the relationship is also available on views listing 'node revisions'.
- adds a similar relationship for userref fields.
Leaving open, since there is still a little more work to do
- in D6, the relationship used a dedicated 'content_handler_relationship' handler, that added the ability to restrict the relationship on a given delta (for multiple fields)
- In addition to adding the relationship, CCK D6 did a little more massaging to the Views data :
replace the filter handler by an 'in' operator
use node.title (resp users.name) in argument summaries
Comment #43
yched CreditAttribution: yched commentedAlso, it seems that (Field API) fields (body, image...) added through the relationship are not displayed in the View (display the body of the referenced node).
Base properties (node title...) added through the relationship work OK, though.
[edit : created #1038240: Field API fields not displayed through a relationship about this]
Comment #44
jakonore CreditAttribution: jakonore commentedsubscribing
Comment #45
mshaw CreditAttribution: mshaw commentedI have the same issue which is a pain with the project I'm working on now. Relationships for node title works great, relationships to images of the same node, not so much.
Comment #46
Martijn Houtman CreditAttribution: Martijn Houtman commentedI can confirm #45 with the latest Reference module. Not sure if Reference or Field API is at fault.
Comment #47
kinesin CreditAttribution: kinesin commentedSubscribe
Comment #48
nstahl CreditAttribution: nstahl commentedSubscribe
Comment #49
yched CreditAttribution: yched commentedre @ my own #43 : "Also, it seems that (Field API) fields (body, image...) added through the relationship are not displayed in the View (display the body of the referenced node)."
I was on crack (or rather I was tracking the wrong git branch). Works fine with current Views 7.x-3.x
Comment #50
shawnb-1 CreditAttribution: shawnb-1 commentedSubscribe
Comment #51
jcarlson34 CreditAttribution: jcarlson34 commentedDid patch #42 get committed to the latest dev version?
I see that the Jan 30 dev version of References now has the code from #42 included.
Everything works in Views. So is this issue RBTC and Fixed?
Comment #52
Les LimIssue stays open per yched's notes in #43:
Comment #53
jcarlson34 CreditAttribution: jcarlson34 commentedThanks for that Les Lim. I reread #43 and apparently I missed this line somehow:
Was just confused that code made it in but it wasn't fixed yet. Makes much more sense now in context...
Comment #54
Thoor CreditAttribution: Thoor commentedSubscribe
Comment #55
yched CreditAttribution: yched commentedActually, let's handle the remaining tasks in separate threads. The 'relationship' part is fixed.
Comment #56
yched CreditAttribution: yched commentedCrap. The 'relationship' part is not completely over, we still need to add the dedicated handler.
For the other two points, I opened
#1046886: [release blocker] Use the 'many_to_one' views filter handler
#1046898: [release blocker] use node.title (resp users.name) in Views argument summaries
Comment #57
yched CreditAttribution: yched commentedThus, marking as release blocker.
@Thoor : addigning an issue to yourself means you intend to work on a patch :-). If that's the case, feel free to reassign.
Comment #58
hansfn CreditAttribution: hansfn commentedMy status is identical to comment 31: "The reference works, and I can show the ref'd node-title and even the 'rendered node' of the node-reference. But if I add a field of the referenced node, this data does not get fetched. Or, if both content types contain the same field, the field-value is shown of the main-node, not of the referenced node."
I'm using Views 7.x-3.0-alpha1 and Node Reference 7.x-2.x-dev (as released today) - no patches applied.
Comment #59
Les Lim@hansfn: you should use the latest Views dev, not views-7.x-alpha1.
Comment #60
hansfn CreditAttribution: hansfn commentedThx, that solved it. This bug is fixed for me (but I guess I might need the "dedicated handler" even if I don't understand what it is).
Comment #61
hexabinaerHad the same prob as in #58/#31. Solved it for me, too. Thanks a lot!
Comment #62
dougvann CreditAttribution: dougvann commentedsubscribe
Comment #63
yched CreditAttribution: yched commentedAttached patch adds the relationship handler - adds an option to select a delta to restrict the relationship.
Should be a no brainer, this is more or less directly copied from CCK D6. I'll try to test a little more extensively tomorrow, and will probably commit pretty soon.
Just like with #1046898: [release blocker] use node.title (resp users.name) in Views argument summaries, the views handler needs to be exposed by a wrapping module. Thus, patch introduces references.module.
Comment #64
yched CreditAttribution: yched commentedTested both noderef and userref, works fine.
I'll commit this tomorrow night if no one objects.
Comment #65
yched CreditAttribution: yched commentedCommitted #63.
Comment #66
Nikro CreditAttribution: Nikro commentedHey,
I have just updated the Node Reference module and Views module (Views-7-3-dev) (before that I had 7th Feb dev-version and I don't quite remember what was the Node Reference), anyhow, before that I could fetch image fields from the referenced nodes, and now it returns empty image fields (while other fields work well).
I'm pretty new in issue tracking so if I won't switch to active.
Comment #67
DavidHadaller CreditAttribution: DavidHadaller commentedEcho @Nikro's comments. In the referenced node in the view, image fields are showing up as blank, while others (e.g. title) are showing up as expected. This is my first time trying this, so I can't say whether it was working before or not.
I am using:
references.info,v 1.1.2.1 2011/02/15 21:11:52 yched Exp $ \ version = "7.x-2.x-dev" (no patches)
views.info,v 1.7.6.60 2011/01/05 21:34:52 dereine Exp $ \ version = "7.x-3.0-alpha1" (no patches)
I'll reply if I find a solution.
Thanks,
Dave
Comment #68
johnv@DavidHadaller, please upgrade to latest Views-dev first; alpha-1 has to much open and already fixed issues.
Comment #69
yched CreditAttribution: yched commentedAlso, make sure you enabled the new 'references' module.
Comment #71
MathRo CreditAttribution: MathRo commentedsub
Comment #72
DavidHadaller CreditAttribution: DavidHadaller commentedThanks for the help! The part of my project that required node references is on hold for the moment, I'll report back if there is still a problem but I'm guessing the dev version of views will take care of it. Thanks!
Comment #73
willvincent CreditAttribution: willvincent commentedThis does not work properly with the latest release of views.
When used as a relationship, it doesn't alter the output.
For example, I pass in a node id, and have a view that grabs all nodes (of the same type) that have this node id in a reference field. Rather than returning the list of nodes that reference this ID, it returns just the node with the ID passed in (as if the relationship weren't specified at all)
Comment #74
yched CreditAttribution: yched commented@willvincent : can you post an export of your view (in an attached .txt file) ?
Comment #75
willvincent CreditAttribution: willvincent commentedI'll have to recreate it when I have time.. I've already dumped the DB and moved back to D6 for the time being. :\
Deadlines, ya know...
I'll see if I can get you something within the next day or so though.
Comment #76
basicmagic.net CreditAttribution: basicmagic.net commentedsubscribe
Comment #77
DoctorEternal CreditAttribution: DoctorEternal commentedsub
Comment #78
kjeldahl CreditAttribution: kjeldahl commentedI'm still having trouble showing an image field from a referenced node. Is this supposed to have been fixed yet? In my case I have a content type A that references content type B, which again refererences a content type C with an image, and I'm trying display that image in a custom view that lists entries of A. The image field from C appears in the "entity shortcut" help for rewriting, so it seems to figure out that it should be available through the relationships, but it never appears (it's treated as empty, according to my "text to display when empty" setting).
Comment #79
johnvkjeldahl, please check if you have the same problem when you create a view with only B and C.
Also make sure that the 2nd relation B->C depends on the first one A-> B.
Comment #80
kjeldahl CreditAttribution: kjeldahl commentedThanks for responding. I redid everything again, verifying the relationship setup you mention, and suddenly everything works. I know I tried this earlier as well, so I would speculate that me upgrading everything - including Drupal 7 and the views module - to dev releases may have helped. Anyway, seems to work great now, thanks!
Comment #81
yched CreditAttribution: yched commentedOK, setting back to fixed for now, until someone can provide an actual view that doesn't work.
Comment #83
Vote_Sizing_Steve CreditAttribution: Vote_Sizing_Steve commentedI'm having the same 'no relationships in fields/filters' with Views 7.x-3.x-dev and References 7.x-2.x-dev.
Any advise is appreciated.