It would be fantastic if it was possible to map incomming data to Node Reference fields. It is my only hurdle for importing a lot of data which I have customized into feeds from an export script I have.
The nodes are related, all the imported books are related to authors. First I import the author feeds, then I import the book feeds. The books should then use Node Reference to reference authors.
Using taxonmy for this might be possible by letting the Author nodes be sticky, but I would get a listing of all the books on the same page as the author, and not in the way I would like them; since I have views for the book listings already.
Comment | File | Size | Author |
---|---|---|---|
#36 | feedapi_mapper_nodereference.inc_.txt | 1.75 KB | nemchenk |
#32 | feedapi_mapper_nodereference.inc_.txt | 1.75 KB | nemchenk |
#31 | feedapi_mapper_nodereference.inc_.txt | 1.97 KB | ncameron |
#30 | feedapi_mapper_nodereference.inc_.patch | 2.36 KB | ncameron |
#26 | feedapi_mapper_nodereference.inc_.patch | 2.15 KB | ndm |
Comments
Comment #1
wmclark CreditAttribution: wmclark commented+1 for this - I have a similar need. CCK Reference Fields are commonly used for most sites.
Comment #2
wmclark CreditAttribution: wmclark commentedI went ahead and gave this a shot. It currently only handles the $feed_element as a string so nid's won't work in the patch I wrote. The string must match exactly to the referenced node title.
It seems to be working on my test site.
Please test and report.
Comment #3
wmclark CreditAttribution: wmclark commentedForgot to mark as "needs review".
Also, I wanted to mention that even if the field being mapped to is a required field, if no valid nodes are found, then the node is created anyway.
Is this a bug in FeedAPI not using the validate step of nodeapi or is this just something that isn't supported yet?
Comment #4
pkej CreditAttribution: pkej commentedI think that is the way it usually works. I'll give your patch a run around asap.
Comment #5
pkej CreditAttribution: pkej commentedI tried this yesterday, and I had problems getting it to work. I will try on a clean install tonight (I hope) and detail what I do on the website after registering the first account on the site.
I have high hopes for this functionality.
Comment #6
alex_b CreditAttribution: alex_b commentedWaiting for pkejs findings here before I test myself.
Comment #7
pkej CreditAttribution: pkej commentedThese steps were performed on a Drupal 5.7 fresh installation.
That started up the initial modules; had to bump up the memory_limit of PHP to 16 MB at this point before continuing.
This should give me two content types where one should be able to reference the other. Now I needed to add an "Author" and a "Feed Story" just to see that I can reference an "Author" from the "Feed Story".
Now it is time to create the Feed
Next step is to create the mapping.
So, there it is. I am able to select the mapping for the feed, but the mapping never happens in reality.
To verify that it is the autonodereference at fault, I created a required text field called "Original Author" in the "Feed Story" node type. That field showed up after I deleted the old entries and refreshed the feed.
I also tried turning on Clean URLs, for some modules in the past it has been an issue wether it has been on or off.
Best regards,
Paul
Comment #8
pkej CreditAttribution: pkej commentedOK
I have misunderstood how it works.
I added an Author named "drupal.org - Community plumbing", and now it automatically appeared. I was under the impression from Comment #3 in this thread that the referred node would be created if it didn't exist.
Upon rereading with the knowledge of how it works I now understand that wmclark meant that the feed node was created regardless.
So, no problems, it works here.
Best regards,
Paul
Comment #9
wmclark CreditAttribution: wmclark commentedSorry for the confusion!
These are limitations because of other modules:
1. nodereference.module will not create new nodes if the title does not exist
2. FeedAPI Node does not validate fields before creating nodes. (So nodes might be created with invalid data)
3. FeedAPI Node does not allow you to moderate which feed items should be created as nodes. (Nodes with blank required fields can be created and published. Unwanted/Unrelated feed items can be created.)
I've created feature requests for some of these limitations.
Comment #10
Summit CreditAttribution: Summit commentedSubscribing, somewhat the same feature request asked here:http://drupal.org/node/241226#comment-792378, right?
If not sorry to interrupt.
Greetings,
Martijn
Comment #11
pkej CreditAttribution: pkej commentedWorks here.
Comment #12
kehan CreditAttribution: kehan commentedsubscribing
Comment #13
vanderlip CreditAttribution: vanderlip commentedThanks for this node reference mapper!
I am using the Node Reference Mapper in #2 with Feed Element Mapper 5.x.1.x-dev. The first time I run a feed refresh after creating (or after deleting all feed items), the mapper works flawlessly, but on each subsequent refresh (either manual or cron), new node references are not mapped to the feed items. The new feed items (nodes) are created correctly and other Feed Mapper Mapped items, CCK Date, and links, are mapped correctly, but the node reference is not mapped.
The node references that are not being mapped in subsequent refreshes are the same as those that were successfully mapped in the first refresh, so I don't suspect there there is a problem with invalid node reference data.
Any assistance would be greatly appreciated.
Comment #14
vanderlip CreditAttribution: vanderlip commentedUpdate to #13
Upon closer examination, node reference mapper appears to work sporadically after the first refresh (which works 100% correctly). For instance, in a resent refresh 1 of the 4 new feed item's node reference values were mapped, the other three feed items were not mapped, even though the value to be mapped was mapped correctly in a previous refresh. I have checked the feed and all the data to map correctly is there.
Thanks again for any ideas.
Comment #15
alex_b CreditAttribution: alex_b commentedChanging status as a response to #14
Comment #16
scottrigbyUpdated patch for 6.x-1.x-dev. I haven't been able to reproduce the problem from #14 in D6 with this patch.
D5: _nodereference_potential_references($field, $return_full_nodes = FALSE, $string = '', $exact_string = false)
D6: _nodereference_potential_references($field, $string = '', $exact_string = FALSE)
See http://api.freestylesystems.co.uk/api/function/_nodereference_potential_....
Any hesitations for including this in 6.x?
Comment #17
jesss CreditAttribution: jesss commentedI just tested this patch and it didn't work for me. This may be because I'm using 6.x.-1.0-beta4, not 6.x-1.x-dev, but just in case it's helpful, I thought I would post my results.
However, it did work when I replaced the
else if ($op == 'map') {
section with the matching section from feedapi_mapper_content.inc, replacing$field[0]['value']
with$field[0]['nid']
.The original code from the patch
The code that worked for me
Comment #18
alex_b CreditAttribution: alex_b commentedNeeds a patch.
Comment #19
jesss CreditAttribution: jesss commentedHere you go. This is my very first patch -- please be gentle. :-)
Comment #20
patchak CreditAttribution: patchak commentedThis does not work for me, I tried with node titles as the reference and not the nid's maybe that's the reason.
Using beta 7 patched version from no. 19
Patchak
Comment #21
jesss CreditAttribution: jesss commentedThe patch matches on nids, not titles. Since the title isn't necessarily unique, matching on title could open the door to a lot of potential mis-matches.
Comment #22
alex_b CreditAttribution: alex_b commented@jesss - I only see this now, but you've patched the patch in #19.
Can you roll a new patch that includes the entire mapper? Hint: You will need cvsdo for adding a new file to the module.
Comment #23
patchak CreditAttribution: patchak commentedWell In my use case I have only use for titles, so I think that would be a choice for a user...
I reverted back to the original mapper for d6 in no.16 and that one works fine. I think we should offer a choice to use either titles or nid's for the mapping, since most clients would have titles and not nid's in their legacy data exports...
Patchak
Comment #24
alex_b CreditAttribution: alex_b commentedComment #25
looplog CreditAttribution: looplog commented+1
Comment #26
ndm CreditAttribution: ndm commentedI can't understand interest to map to node id. How can a feed know your nodeid???
So i have take code from #2 and adapt with standards of 6.x-1.0. Now link is made with node title, if doesn't exist even if you have a autocreate, nothing happens (more sure, i think for miss orthographic problem).
So for me that's work, and for you?
Comment #27
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedsubscribing
Comment #28
MikMik CreditAttribution: MikMik commentedHi there,
I tried the patch in #26, but it didn't work at all! I don't see a difference in the mapping-screen. Actually, this counts for all the patches in this thread.
What I noticed in the #26-patch is that the function it declares is "content_feedapi_mapper", but this function has already been declared in another file, so php throws an error (cannot redeclare function etc).
Are there any updates for this highly anticipated feature?
Comment #29
Jax CreditAttribution: Jax commented@26:
I'm writing my own eparser which can retrieve the correct related node id's throught the guids.
Say I have a first feed with authors:
I've written an eparser to turn those ids into guids for feedapi. Then I have a second feed with books:
I've written a second eparser that can take the id from the author and fetch the corresponding nid from the feedapi_node_item table. In this case I need to be able to map the nid.
Comment #30
ncameron CreditAttribution: ncameron commentedHad problems with some of the above inc files / patches. I hashed the attached patch together from using other examples in the folder. Works really well for me.
Comment #31
ncameron CreditAttribution: ncameron commentedattached to this is original inc file which might be easier to use than the patch
Comment #32
nemchenk CreditAttribution: nemchenk commentedI couldn't get #30 or #31 one to work with Feed Element Mapper 6.x-1.3, so I used them to write a mapper that does work, which I attach to this post.
Comment #33
Summit CreditAttribution: Summit commentedHi, would be great to move this also to feeds (www.drupal.org/project/feeds), while feedapi will move completely to feeds.
greetings, Martijn
Comment #34
jcbou CreditAttribution: jcbou commented#30 31 and 32 still don't work for me. Could you help?
Comment #35
nemchenk CreditAttribution: nemchenk commentedI could try with #32, jcbou -- what's the problem?
Comment #36
nemchenk CreditAttribution: nemchenk commentedUpdated mapper for D6 syntax -- the previous mapper would match the first partial title match, not an exact match.
Comment #37
501cGeek CreditAttribution: 501cGeek commentedI have essentially the same need, importing news stories from RSS and creating a node reference in each story to the node of the journalist that wrote the story. But I'm trying to use Feeds instead of FeedAPI since it's the new hotness, also we have a need to import CSV data which Feeds also provides.
I created a Feeds importer that is attached to the journalist node type, which puts a field in each journalist node for the URL of an RSS feed of stories for that journalist. Perfect. I just want to add a node reference in each imported feed story that links to the journalist node that feed is attached to.
Any advice?
Comment #38
501cGeek CreditAttribution: 501cGeek commentedsorry if that question was offtopic, to somewhat answer it... it looks like there are patches to this effect, that are moving toward someday being included in the Feeds module, but for the short term maybe FeedAPI offers more options relevant to this specific task. Need to investigate both options further, patch Feeds or switch to (and possibly patch) FeedAPI...
http://drupal.org/node/724536
http://drupal.org/node/632920
Comment #39
nemchenk CreditAttribution: nemchenk commented"for the short term maybe FeedAPI offers more options relevant to this specific task."
Precisely why, while Feeds may be the "new hotness", I continue to use the "old and busted" FeedAPI for now :)
Comment #40
hanmant.sapkal CreditAttribution: hanmant.sapkal commentedHow to use this file?
Comment #41
alibama CreditAttribution: alibama commentedpatch 36 worked fine for me - with ~40,000 nodes and two references per node the import took ~2.5 days...