It's my understanding that for Feeds to support node_reference and user_reference fields in Drupal 7, a mapper will be needed. This is effectively the same issue as #724536: Mapper for nodereference field in Drupal 6, but for Drupal 7 instead of Drupal 6. I'm bundling node_reference and user_reference together since (for now at least), support for both is being provided by the same module, namely References.
I've taken a first stab at creating the necessary mapper. (It's also my first time writing code for Drupal, so apologies for any standards I've overlooked). So far I've only done a few basic tests -- and I'm guessing that a proper suite of test functions will eventually be needed. But I wanted to post what I've done before going too much further in case there's any feedback.
Comment | File | Size | Author |
---|---|---|---|
#132 | references-feeds-followup-988856-132.patch | 569 bytes | yched |
#112 | references_feed_inc-988856-112.patch | 13.55 KB | grasmash |
#105 | references_feed_inc-988856-105.patch | 13.5 KB | grasmash |
#96 | references_feed_inc-988856-84_updated.patch | 13.05 KB | mukhsim |
#84 | references_feed_inc-988856-84.patch | 12.93 KB | presleyd |
Comments
Comment #1
Nephele CreditAttribution: Nephele commentedI'm providing a new patch based on the most recent version from #724536: Mapper for nodereference field in Drupal 6 -- I based my original patch on an out-of-date version.
Also I've assigned the issue to myself to indicate that I'm planning to add the test class once I get the time.
Comment #2
Anonymous (not verified) CreditAttribution: Anonymous commentedWorks like a charm. I tried it with a simple node reference (select list) with about 100 nodes. Mapping without a problem.
Comment #3
johnvI used the patch with D7-RC3, and it works perfectly. Thanks!
Comment #4
johnvAfter some testing, I cam across the following error:
If a line item of the import-file contains references to nodes that do not exist, an info-message is raised, and a new node is created for the incorrect item, resulting in corrupted/incomplete data, even if the nodereference is set to Required Field in the Content Type.
IMO in this case, the import-line should be rejected.
Comment #5
joshuajabbour CreditAttribution: joshuajabbour commentedFYI, I reworked #724536: Mapper for nodereference field in Drupal 6 a bit, removing some issues. See comment #83.
Comment #6
attiks CreditAttribution: attiks commentedI think this is RTBC
Comment #7
jackbravo CreditAttribution: jackbravo commentedSubscribe
Comment #8
ropaolle CreditAttribution: ropaolle commentedSubscribe
Comment #9
retolist CreditAttribution: retolist commentedSubscribe
Comment #10
mattbk CreditAttribution: mattbk commentedsuperscribe
Comment #11
johnvI'm very happy with Nephele's mapper. I have added support for GUID/URL.
Since my usecase is very limited, I have not touched anything as mentioned in #5.
Attached patch is a delta, so you should apply it on top of #1.
Comment #12
bambilicious CreditAttribution: bambilicious commentedSubscribing.
Comment #13
mattbk CreditAttribution: mattbk commentedFor the patched version, in what format is the input for the reference fields? Is it ID or title or a combination, or what? Just curious before I attempt to patch.
Comment #14
johnvdakotaroar, I only use the GUID, don't know how to use the URL. My use case is:
- Feed 1: Create nodes of Content type A, setting the GUID/URL:
- Feed 2: Create nodes of Content type B, getting the GUID/URL of Feed 1:
The advantage is that you can map to 'technical' fields. Users may change Titles, etc. without disrupting future feed imports.
(N.B. Somewhere out there is also a patch mapping to the node-field itself, bypassing the Feeds-GUID table, which is way better. This allows mapping to node created by users instead of feeds)
Comment #15
mattbk CreditAttribution: mattbk commentedNM the message below, I had applied the patch incorrectly and created the references.inc file in the feeds root directory, not the mappers directory. Looks better now, testing...
----------------------
Forgive me for just not being entirely familiar with how Feeds works, but these patches should allow me to map a field in an incoming file (a CSV, say) to a field that is a node reference, correct? When I'm setting up mappings, no node reference fields appear in the dropdown menu. I've run update.php and cleared the caches but I still don't see them. I was looking through the module code in references.inc but I'm not a module developer so I don't really know how it's supposed to go together.
Pounding my head against a wall, glad you guys (like johnv) are around to baby-step people like me through things! The funny part is that I managed to patch things correctly this time around.
Comment #16
funkeyrandy CreditAttribution: funkeyrandy commentedgreat patch! but how would you tag to multiple node references items..for example:
two node reference author nodes tagged to a single article...im using csv import and can delimit by a comma or anything else...
is see you limit to one:
thanks!
Comment #17
funkeyrandy CreditAttribution: funkeyrandy commentednevermind! i figured it out....just change line 108
$value = array($value);
to
$value=explode(",", $value);
and separate by a comma in your csv
Comment #18
attiks CreditAttribution: attiks commentedCan we get this in, and create a new issue for #17?
Comment #19
johnvI am not sure either, if #17 is the correct patch for everyone.
Feeds does not seem to support multivalue fields, and separators can be different for everyone.
I used Feeds Tamper for multivalue fields; didn't try terms, but there are issues about that; node ref's is now the next case.
But is the fix works for someone, he should apply it. Thanks, funkeyrandy!
Comment #20
funkeyrandy CreditAttribution: funkeyrandy commentedmy code will work for people who have comma delimited output for node reference fields..however, i think the ultimate patch would be to provide users with the ability to choose what separator they want for their needs....i dont have time right now...but hopefully soon!
r
Comment #21
allella CreditAttribution: allella commentedI ran into an issue after applying patch #1 and #11.
Upon importing the following error came up
I updated References module from an older -dev version to 7.x-2.0-beta3. Based on grep and #1150004: _node_reference_potential_references() signature changed in node_ref.module I updated line 153 of sites/all/modules/feeds/mappers/references.inc
from
to
Not sure if that's a good fix, but it works for me. A better fix may involve updating the patches above to use node_reference_potential_references(), instead of _node_reference_potential_references_standard() or _node_reference_potential_references
Comment #22
Dave ReidComment #24
johnv@orangecoat-ciallella , Issue #1150004: _node_reference_potential_references() signature changed in node_ref.module deals with this API change. This is fixed in References-release may 15th or later.
Interpreting that patch, we should either be able to use #11 again, or use node_reference_potential_references instead.
Comment #25
TimelessDomain CreditAttribution: TimelessDomain commentedApplied patches from #1 & #11. "Target" shows the node reference fields but "Source" does not. Currently taxonomy allows mapping from parent feed, but as of now references does not #1074662: Inherit properties from parent feed node (taxonomy, author, OG, language)
If someone wants some funds to get this issue & #1074662 solved, I would be willing to chip in
Comment #26
marcjpb CreditAttribution: marcjpb commentedHey guys, I did #1, followed by the patch at #11 and was able to import everything. I used GUID to link my child node to his parent.
The only problem I had was, since I am on a multi language environment, I had to change all the reference to $field['und'] to $field['en'] and my content type is in english by default.
Comment #27
inversed CreditAttribution: inversed commentedsubscribe
Comment #28
rickmanelius CreditAttribution: rickmanelius commentedsubscribe
Comment #29
rickmanelius CreditAttribution: rickmanelius commentedAs per #21, this patch needs to be rewritten to comply with the alterered functions in the relations module {#1150004].
So this patch uses
$validate_function = '_node_reference_potential_references';
$matches = $validate_function($info, $v, 'equals', array(), 1);
But references now has the form
Not a major rewrite, but some changes nonetheless.
Comment #30
rickmanelius CreditAttribution: rickmanelius commentedI've added to the patch in #1 to include the new function format for the references module described in #29.
This ignores the patch in #11 now. I can confirm this works when matched with several other patches.
#973876: NULL $config causing "Unsupported operand..."
#1169986: Fatal error: Class 'FeedsPlugin' not found
I was able to use a feed importer to pull in a node title and a node reference by node title using this patch. Feedback is appreciated.
Comment #31
stwardzi CreditAttribution: stwardzi commentedsubscribe
Comment #32
BlakeLucchesi CreditAttribution: BlakeLucchesi commentedI took a moment to add support for mapping parent node references as a feed source to the child nodes. This has been tested on just my machine with a few different feeds. Would be great to get a few others to review and make adjustments as needed. This patch also includes the work submitted in #30 to map the targets to the children.
Comment #33
BlakeLucchesi CreditAttribution: BlakeLucchesi commentedI also wanted to mention that I get this notice when importing nodes:
Notice: Undefined offset: 2 in references_feeds_set_target() (line 158 of /Users/blakelucchesi/Sites/xprize/sites/all/modules/feeds/mappers/references.inc).
It has to do with this line in the target mapping code:
// Determine whether we are matching against the title/user or nid/uid, and whether duplicates are allowed.
list($target, $match_key, $duplicates) = explode(':', $target, 3);
It assumes there are 3 parts to the $target string, which isn't true when selecting the target option without duplicates. Certainly a nice one liner of code, but it looks like the assignments need to be split up since you can't count on there being three keys after the explode.
Comment #34
rickmanelius CreditAttribution: rickmanelius commentedI'm only worried that we've put up so many versions of this patch that the maintainer won't have time to iterate through without review by the community.
Is it possible to review #30 or #32 and get the merged? Then we can add more features on top with futher testing from the community in the dev branch...
Comment #35
dotman CreditAttribution: dotman commentedCould someone please tell me what is the best patch(s) to apply for user and node reference? I'm in particular need of user at the moment. And should the field widget be set to list and not auto complete, or doesn't that matter. Thanks.
Comment #36
Micha1111 CreditAttribution: Micha1111 commentedI have tested patch #32
After following changes in function references_feeds_set_target($source, $entity, $target, $value) {
I can import nodereferences by given nid's in csv files:
delete pre underscores in validate function names
_user_reference_potential_references => user_reference_potential_references
and
_node_reference_potential_references => node_reference_potential_references
$matches = $validate_function($info, '', NULL, array($options['string'])); has too many parameters, because $options includes all 4 needed parameters (see #29)
$matches = $validate_function($info, array($options)); works for me
Comment #37
00trav CreditAttribution: 00trav commentedI tried the patch in#32 with modification from #36.
It seems to always insert the first available node id and user id from the available nodes or users.
Comment #38
00trav CreditAttribution: 00trav commentedI think there is an issue with $options['ids'] = key($matches);
it always spits out the first value of the array. I fixed with adding a manual check against the value passed from the $value array.
Comment #39
Pocketpain CreditAttribution: Pocketpain commentedTried #1 but without result. Surely I'm supposed to get the nodereference in the mapping dropdown list?
Comment #40
dotman CreditAttribution: dotman commentedHey funkyrandy, I think i'm trying to accomplish what you've done. I can have a user reference filed set to unlimited and a csv with the userid's (although i'd prefer using usernames, but that throws an error) in a comma separated field. it will map the correct id to the author is there is only on id, but if i have more than one, my "byline" user reference field is empty.
could you tell me is you're able to map multiple authors to a userreference field for a node, and the exact order of patches you applied to get this to work?
oddly, if I use the patch in the very first post, not #1, i get the above (without the duplicate options), but if i start with the patch in #1, i get ajax errors.
any advice on getting multiple authors mapped to my user reference field would be much appreciated.
Thanks.
Comment #41
dotman CreditAttribution: dotman commentedsorry, i'm at my wits end. can anyone tell me the right patch(s) to use to simply add nodes to a content type that has a user field reference set to multiple/select list pulling data from a csv that has a comma separated list of usid's? I would be in your debt.
Edit: Ok, I've applied patch #32 and#36 and now my field "byline" set to a user reference field is always set to admin, no matter what userid's i put in the csv. If I chang the mapper to User name, I get "no nodes were imported".
Why won't the user reference field work correctly? is anyone getting it to map to a comma separated filed using either userid's or usernames?
Thanks.
Comment #42
TimelessDomain CreditAttribution: TimelessDomain commentedapplied #32, tested, then applied #36 (tried each change individually then together - removing underscores & changing $matches function)
Sources now has "Feed node: Node Reference (nid): field_name" (nid means i should map it by node ID instead of node title, right?)
which was mapped to "Field (Node reference by node ID)"
also tried
Field (Node reference by node title) -- allow duplicate nodes
Field (Node reference by node ID) -- allow duplicate nodes
Field (Node reference by node title)
this did not work though
(note: i switched parser to Common syndication parser temporarily to reveal possible sources. i then copied this text back into the source mappings for the CSV parser. This worked perfectly using taxonomy terms (Feed node: Taxonomy: Taxonomy Name), but its not working for the node reference field. I'm using a multi-valued node reference field, but as of now i just need 1 node reference field mapped, though we should accommodate for multiple values eventually.) Thanks
Comment #43
TimelessDomain CreditAttribution: TimelessDomain commentedComment #44
dotman CreditAttribution: dotman commentedi updated my references module to the dev (from beta 3), and am using Curent Dev version of Feeds.
When i put in a userid in my csv, it just poulates my node with the first user in the list, so the users are all the same.
Is anyone getting this to happen correctly? With either userid or user name? Multiple values?
Thanks.
Comment #45
dotman CreditAttribution: dotman commentedhey 00trav, could you share the validating code you used to fix the uid from just using the first value in the array instead of the one specified in the csv. Would really help me out.
Comment #46
00trav CreditAttribution: 00trav commentedso this is what i got
replace $options['ids'] = key($matches); //(I think this is around line 214, i put a bunch of debug code in mine so the line numbers are off from the patch file)
with this
I only tested this with using NID and UID (not name and title). also, my fields are unique, so i didn't test multiple values.
Also, i have no idea if there is proper validation, this is pretty much a total hack just to get it to work. I also noticed another issue, when importing nodes to update, it doesn't update the reference fields.
Comment #47
marcoscanohello all
I've tried patch on #32, then I can see the options
Field (Node reference by node title) -- allow duplicate nodes
Field (Node reference by node ID) -- allow duplicate nodes
Field (Node reference by node title)
in the mapping section, but when I attempted to import the CSV file I got the error:
Fatal error: Call to undefined function _node_reference_potential_references() in /.../sites/all/modules/feeds/mappers/references.inc on line 198
In my CSV file I'm trying to import two fields that are node references, and selected "Node reference by node title"
Any suggestion on what I may be doing wrong?
Thanks in advance, I'm quite new to building sites with Drupal, still struggling with some very basic settings...
Comment #48
marcoscanosorry everybody, just applied the modification indicated on #36 and now it imports everything, thanks for the patch.
Just having some issues with one field (date), which is not being correctly imported (it's taking current GMT time, instead of the one in the csv file) but that's another issue..
sorry for bothering
Comment #49
Micha1111 CreditAttribution: Micha1111 commentedOK, I have tested the code including the changes #46 with feed settings nid and (allow duplicate nodes).
I tried to import 4 records from csv file
1st with correct nid
2nd with the same correct nid
3rd with a different but correct nid
4th with a different and wrong nid by design
3 records were imported
The 4th record validation failed as expected, but two sql error messages are shown
Seems like Feeds module is trying to insert the wrong record in database table, although the validation failed before.
I don't know, which function causes this error.
Comment #50
00trav CreditAttribution: 00trav commentedHave you tried dumping the $matches variable (contents returned from $validate_function($info, array($options)) )?
I think the issue might be with the validate function.
Comment #51
dfrishberg CreditAttribution: dfrishberg commented@Pocketpain re. #39, I apologize if this is a dumb question, but I fell for this problem. Are you sure you're clicking the "Add" button and not the "Save" button?
Comment #52
muhleder CreditAttribution: muhleder commentedHere's a patch rolled against dev which builds upon #32, #36, #46. It also includes a fix removing
$sources = array();
fromwhich obviously wipes out any existing sources.
Comment #53
TimelessDomain CreditAttribution: TimelessDomain commentedComment #54
Pocketpain CreditAttribution: Pocketpain commented#51: I was adding... but now I worked it out.
Comment #55
00trav CreditAttribution: 00trav commentedTested #52 and it worked (however, I haven't updated to drupal core 7.4 yet). Will retest tonight.
@muhleder - thank you for wrapping the edits into one patch!
Comment #56
Summit CreditAttribution: Summit commentedSubscribing, greetings, Martijn
Comment #57
Summit CreditAttribution: Summit commentedHi, It also works on Core 7.4 :)
Would it also possible to have term reference added please, see also this forumpost: https://drupal.org/node/1191036 ?
EDIT: Term reference works from patch: http://drupal.org/node/988856#comment-4693684.
Greetings, Martijn
Comment #58
TimelessDomain CreditAttribution: TimelessDomain commented@Summit - term reference already works as per #959984: taxonomy_node_get_terms doesn't work with drupal 7
#54 & #55 look like they are using 2 different solutions.
Can someone please step in & pick the best method, then create a final "combined" patch? we don't want this issue to continue to grow with non-aligned methods otherwise it may become too convoluted (& get delayed further as a result). Thanks
Comment #59
paulgemini CreditAttribution: paulgemini commentedsubbing
Comment #60
Steven.Pescador CreditAttribution: Steven.Pescador commentedsubscribe
Comment #61
muhleder CreditAttribution: muhleder commented@TimelessDomain 'Can someone please step in & pick the best method, then create a final "combined" patch? '
That's what I did in #52. Try the patch, if it works, report that it does. if it doesn't report what bugs you've found.
Comment #62
johnvposted wrong file - please continue with #63.
Comment #63
johnvThis patch is based upon #52 and includes mapping against the fields GUID and URL, as stored in table feeds_item. It was posted before in #11.
Comment #64
vinotwit CreditAttribution: vinotwit commentedI also had the "Call to undefined function _node_reference_potential_references" fatal error. I have applied patch #52 and it worked for me - 7.4 Core, using an Xpath mapper import for content node creation with node reference on title, not nid. cc @muhleder
Cheers --Mike
Comment #65
Bevan CreditAttribution: Bevan commentedLooks like this is ready. The attached patch is the same as #63 but actually applies (I got errors with #63) and is a drupal-standard (git) patch.
Comment #66
dboulet CreditAttribution: dboulet commentedPatch in #65 works fine, thank you.
Comment #67
dotman CreditAttribution: dotman commentedDoes #66 support multiple users for a user reference field by name? that would be awesome if possible, since that's what my csv contains coming from another CMS datasource.
dot.
Comment #68
dotman CreditAttribution: dotman commented#66 doesn't work at for me with either username or usid when my field is either:
"24, 25"
"Mary Jane, Paul Smith"
These users definitly exist. am I missing something?
dot.
Comment #69
dboulet CreditAttribution: dboulet commentedHi dotman, maybe try splitting those uids into multiple columns and map each to the reference field.
Comment #70
Bevan CreditAttribution: Bevan commenteddotman; If you are migrating different types of related objects you will probably find that http://drupal.org/project/migrate better suits your needs. You will need development skills (or a developer) to make use of it, but it handles complex data models for one-time imports (such as site migrations) better than Feeds. Feeds is great for recurring imports from a parallel live data source, but is designed for primarily "flat" data sources; i.e. a list of objects of the same type with a list of attributes.
Comment #71
nyl_auster CreditAttribution: nyl_auster commentedsuscribe
Comment #72
jdlind38 CreditAttribution: jdlind38 commentedsub
Comment #73
johnvDotman, you need to make feeds know you are passing an array. You can do this e.g via the explode-function of FeedsTamper.
Comment #74
Summit CreditAttribution: Summit commentedHi, Just used the explode function of Feeds Tamper..it is working great!
Just use another delimeter than the normal feeds delimeter, and you Rock!
greetings, Martijn
Comment #75
SonniesEdge-1 CreditAttribution: SonniesEdge-1 commentedTried this out, and CSV files refuse to import when a NID is specified in the mapper. However, there are no errors reported - final message is "xxx nodes imported", but nothing shows up in the content list. Same CSV imports fine if NID mapper is removed.
Happy to test this out further if anyone can offer pointers.
Comment #76
Summit CreditAttribution: Summit commentedHi, Feeds has problems with numeric values, see this issue: http://drupal.org/node/1019688
This has I think nothing to do with the reference mappers.
For me http://drupal.org/node/1019688#comment-4094658 worked!
Greetings,
Martijn
Comment #77
Bram Esposito CreditAttribution: Bram Esposito commentedThe version in #65 fails to import multiple references. That is similar to the issue for taxonomy in http://drupal.org/node/1039134#comment-4389556 .
I attach a modified version of #65 that can import multiple references: see documentation for drupal_explode_tags http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_ex...
Comment #78
Bram Esposito CreditAttribution: Bram Esposito commentedSorry, wrong attachment.
Use this one instead:
Comment #79
johnv@Bram,
I don't think you should explode the data. This function is a mapper, not a parser.
Your change (If I'm correct) assumes a comma as a separator, which is not always the case.
Multi-values should enter the mapper as an array, not a comma-separated string.
In other issues, maintainer also states that multivalues are not supported. Feeds Tamper does the trick, and you can set your own delimiter there in the UI. See #73, #74 for 2 succesful testimonials.
Comment #80
ShaneOnABike CreditAttribution: ShaneOnABike commented+1 Awesome! When is this going to get rolled into the module.
Comment #81
13rac1 CreditAttribution: 13rac1 commentedI don't want to step on any toes, but this should be added to the References module instead of the Feeds module. It is feeds integration for the reference module and Feeds will soon support the same type of integration as Rules or Views. New file would be named references.feeds.inc. Only problem is a patch is required #1224836: modulename.feeds.inc files are not automatically included, or temporarily a require_once() is needed in references.module. Attached patch uses modified code from #65 for use with the 2011-Aug-02 references git.
Comment #82
johnv+1. IMO, moving the issue to References is the right thing to do.
Until #1224836: modulename.feeds.inc files are not automatically included is solved, you must add the following line to references.module:
module_load_include ('inc', 'references', 'references.feeds');
Comment #83
presleyd CreditAttribution: presleyd commentedThat should read:
module_load_include ('inc', 'references', 'references.feeds');
This patch is a lifesaver for me
Comment #84
presleyd CreditAttribution: presleyd commentedTook the file in #81 and added the line for module_load_include into an implementation of hook_init so that it is no longer necessary to add it as per #82 and #83
This patch works until #1224836: modulename.feeds.inc files are not automatically included is resolved. If this issue is resolved use the patch in #81 instead!
Comment #85
johnv@preselyd, #83, indeed. I edited in #82.
@presleyd, #84. I normally put the include outside any function. Perhaps your solution is better for memory consumtion?
Anyway, I didn't include the module_load_include()-line in the patch, since the final solution doesn't need this line. IMO it's better implement #1224836: modulename.feeds.inc files are not automatically included FTTB.
Comment #86
presleyd CreditAttribution: presleyd commented@johnv After reading up on the Feeds issue more I agree, the line isn't needed. I'll update my post. PS I don't know about memory but using implementing hook_init seemed more Drupalish..
Comment #87
Swipular CreditAttribution: Swipular commentedSubscribe.
Comment #88
jenna.tollersonFYI #1224836: modulename.feeds.inc files are not automatically included has been marked as a duplicate of #1139676: feeds_alter doesn't support hook_module_implements_alter, hook_hook_info and hook_hook_info_alter, so that is the one to keep an eye on.
Comment #89
ropaolle CreditAttribution: ropaolle commentedAnother node reference patch can be found here #1271872: Patch: Node_reference mapper D7. It seems to use different code base than the patch here, meybe you should merge your patches.
Comment #90
breckenr CreditAttribution: breckenr commentedSub
Comment #91
13rac1 CreditAttribution: 13rac1 commented@ropalle I've marked #1271872: Patch: Node_reference mapper D7 as duplicate of this issue.
Comment #92
saitanay CreditAttribution: saitanay commented#81: references_feeds_inc-988856-81.patch queued for re-testing.
Comment #93
johnbarclay CreditAttribution: johnbarclay commentedI applied #84 and used with node references that were both singular and comma separated. Worked fine for me. Very useful. Thanks.
In the import process, I had to create 2 feeds: one to bring in the initial nodes and a second to update the nodes with references. This is because the node references won't validate if the nodes they reference don't exist yet.
Drupal 7.8, current feeds head, References 7.x-2.0-dev
Comment #94
Georgique CreditAttribution: Georgique commentedSub
Comment #95
ryantollefson CreditAttribution: ryantollefson commentedsubscribe
Comment #96
mukhsim CreditAttribution: mukhsim commented#84 did not work with multiple items passed as a single comma delimited value.
Attached is a fix for that.
Mukhsim.
Comment #98
Summit CreditAttribution: Summit commentedHi,
Latest patch (#96), gives me on references:
This error is for every node I want to import.
Thanks for helping in advance!
greetings,
Martijn
Comment #99
jack000 CreditAttribution: jack000 commentedit seems the problem is in isset($options['ids']), which returns true on an empty array. I changed this to !empty($options['ids']) and it worked for me.
Comment #100
Omniweb CreditAttribution: Omniweb commentedfeeds-mappers-references.patch queued for re-testing.
Comment #101
timothykc CreditAttribution: timothykc commentedsubscribe
Comment #102
Summit CreditAttribution: Summit commentedHi,
I think patch #96: http://drupal.org/files/references_feed_inc-988856-84_updated.patch with addon:
Should be queued for re-testing, right?
Greetings, Martijn
Comment #103
presleyd CreditAttribution: presleyd commentedSome other formatting errors in there I believe
Comment #105
grasmash CreditAttribution: grasmash commentedFixed syntax errors in patch from #96, added change from #102.
EDIT: please remember to give git attribution to Nephele and other contributors.
Comment #106
cwithout CreditAttribution: cwithout commentedGood work on the patch. Just installed it and got references working for user by user name
But all the code is in
references.moduleI mean a .inc file in references module directory. Shouldn't the hooks be in their corresponding modules?node_reference_feeds_parser_sources_alter in node_reference.module
user_reference_feeds_processor_targets_alter in user_reference.module
Etc.
Edit: Not saying what you have is wrong, but I was under the impression that best practice is for hooks to be kept with their modules. So if it's in an .inc file, there should be separate files for node_reference module and user_reference module that live inside those module's directories. I can see good reason for wanting to keep them all in one file though.
Comment #107
msamavi CreditAttribution: msamavi commentedThanks all so far.
For me patch 105 does not work when the string contains comma character within the node title, further more I tried the node id (the "Node reference by node title" option) with no success!
Comment #108
johnv@msamavi , this is since #77, where multiple values are introduced. IMO this does not belong in the mapper, as you experience.
This can be added in your own custom code/modification, or better use Feeds Tamper to do this.
Can you remove the part below and test again?
Comment #109
Anonymous (not verified) CreditAttribution: Anonymous commentedThe mapper for Link fileds in Feeds itself does handle multiple valued fields, so I would say this probably does belong in the mapper. However, the handling for comma-separation that is in there should not be included IMO.
Comment #110
johnv@linclark,
Indeed, I could be more precies. Multiple values ARE supported by the mapper. Every single value is a record in the $value array. Making sure that a string is split into more then one value should be done in the parser.
Comment #111
sanguis CreditAttribution: sanguis commentedthank you just what I needed #105 worked for me
Comment #112
grasmash CreditAttribution: grasmash commented@98 - I was having the same error. I made another small change to the patch, which seems to have fixed it. Attached.
Comment #113
colanFor those of you that are considering converting, I've got a Feeds patch for Entity reference over at #1341012: Feeds integration for Entity reference fields that could use some testing. ;)
Comment #114
jack000 CreditAttribution: jack000 commentedIt seems that with this line I am only able to *append* references rather than set them - is this the desired behavior? The other imported fields overwrite the existing content.
a few more suggestions:
- trim white space on node ids
- suppress notices on empty values (I get hundreds of notices when I import stuff)
Comment #115
rtdean93 CreditAttribution: rtdean93 commented#122 worked great. Thanks for this just in time patch.
Comment #116
elliotttf CreditAttribution: elliotttf commentedCode looks good and is working for me.
You might be able to simplify the code a bit by using a common callback for the node_reference and user_reference targets, but I wouldn't say it's critical.
Comment #117
yched CreditAttribution: yched commentedI know very little about Feeds API, so I'll blindly trust the various people reporting in this thread.
Took a brief look at the code, fixed a couple code style issues, and committed.
Thanks all !
Comment #118
tbeckett CreditAttribution: tbeckett commentedThe patches no longer work with the latest version of references. Help!
Comment #119
tbeckett CreditAttribution: tbeckett commentedThe latest version of references kills this patch, and viola no import from feeds...
Comment #120
johnvI understand your frustration, however... resetting title
Comment #121
yched CreditAttribution: yched commentedThe patch has been committed 2 days ago. If you grabbed a version of the code since then, there is no need to apply the patch, the code is already in there.
Now, are you telling me that the current code (that includes the committed patch) doesn't work ?
Comment #122
tbeckett CreditAttribution: tbeckett commentedSorry, I didn't realize that it was going live.
Comment #123
tbeckett CreditAttribution: tbeckett commentedAha! Clear Caches, and it works perfectly. Yes, today I got to be that NOOB! Thank you guys for making things work, responding so fast, and kicking butt.
Comment #124
yched CreditAttribution: yched commented:-)
Back to closed, then.
Comment #125
rickmanelius CreditAttribution: rickmanelius commentedAmen! A big thanks to everyone for pushing this through :)
Comment #126
luis_san CreditAttribution: luis_san commented#112: references_feed_inc-988856-112.patch queued for re-testing.
Comment #127
yched CreditAttribution: yched commented@luis_san - kada... : Why back to 'needs review' ? The patch is now in, there is nothing to review anymore.
Comment #128
tbeckett CreditAttribution: tbeckett commentedInteresting. The new version seems to have issues with csv's that have comma's in their quote defined strings. EG:
"Sustainability assessment of slash-and-burn and fire-free agriculture in Northeastern Para, Brazil"
Gets truncated after Para.
Any thoughts?
Comment #129
johnvYes, this got in as per #77.
I got tired of promoting Feeds Tamper to parse multiple-values in several mapper-issues..
This should reverse it:
Comment #130
yched CreditAttribution: yched commented@johnv: is that a code change that should be committed to references.feeds.inc ?
Comment #131
johnvIMO, yes.
BTW, I changed above comment/code to latest version. I still use an old version, so cannot provide a proper patch..
Also,
we can ditch the references.module part, since this issue has been committed on 20-dec-2011:
#1139676: feeds_alter doesn't support hook_module_implements_alter, hook_hook_info and hook_hook_info_alter
#1224836: modulename.feeds.inc files are not automatically included
But now we are getting unscientific...
Comment #132
yched CreditAttribution: yched commentedCommitted the attached patch as per #129.
I'm not using Feeds myself, nor do I know the API, so I'm blindly committing whatever you guys think is valid...
About references_init() : we can actually not simply remove it and rely on hook_hook_info(), since references.feeds.inc contains hooks implementations on behalf of node_reference and user_reference. Left this part as is for now.
Comment #134
dhakshinait CreditAttribution: dhakshinait commentedcan you tell me how to import multiple node reference by feeds using UI?
Comment #135
johnv@dhakshinait,
you can't using Feeds UI.
As long as Feeds does not have an option for specifying the separator You have some options:
-You can use Feeds Tamper module. This allows you to 'tamper' with the data before passing it to Feeds. e.g. explode the comma-separated string into an array.
- You can try some Feeds-issue (can't find it right now) that allows you to have each value in a separate column in your csv/xml.
- modify the code using #16/#17.
Comment #136
dhakshinait CreditAttribution: dhakshinait commentedI have tried Feed tamper module, i choosed "explode' plugin from that module for particular multi node reference field and imported a csv data but it imported first value in that columns For example i tried to import values in column(value1,value2,value3). It imported only "value1" from that column..
Comment #137
johnv@dhakshinait , you better check the Feeds issue queue. Your problem/feature request is not particular to the references mapper.
It will happen to any multi-value field.
Comment #138
dhakshinait CreditAttribution: dhakshinait commentedThanks for you help. i found that I have done a mistake in field setting of node reference field[didnt choose unlimited value ] and now
i can able to import multiple values for node reference using feed tamper module....Once again thanks a lot....
Comment #139
ambientdrup CreditAttribution: ambientdrup commentedI'm also experiencing this issue with trying to import a comma separated list of node titles into a node reference field. I can only import one value but if I have multiple values comma separated it says on the import that the node can not be found (even though the node is there). See my other post in both the References and Feeds issue queues: http://drupal.org/node/1518216
I did try using Feeds Tamper and setting an explode plugin with comma separation. I also tried the patch in #112. Neither seems to have fixed the issue.
-Trevor
Comment #140
ambientdrup CreditAttribution: ambientdrup commentedPlease see my additional comment via this issue which is related to #139: http://drupal.org/node/1518216#comment-5839556
-Trevor
Comment #141
ambientdrup CreditAttribution: ambientdrup commentedOk I've spent a good deal of time debugging this today and I've been able to make it work. I can now import multivalue node references using the References module via Feeds per this:
1) I made sure to install the dev version of the References module
2) I installed the dev version of the Feeds Tamper module
3) I installed the alpha4 stable version of Feeds
4) I determined that I can get the multivalue node reference in using pipes (as opposed to commas) as the separation in both the CSV file and in the Feed Tamper module configuration for the mapping; and then in the Feeds mapper we need to use the | as the separator. I've also determined that this import process using pipes will work via both PC or Mac (I was concerned that maybe the Mac was causing issues on the import).
5) Additionally if you have "" wrapping the array or the values in your CSV it does not work. This still appears to be a bug. But without the "" and just using the pipes works.
So the values in the CSV should be:
node1|node2|node3
I've also determined that the ID column header in the CSV that maps to the GUID needs to be lowercase id and also tweaked to be lowercase in the actual importer mapping. If it’s uppercase it throws an odd SLYK error in the CSV file if you try to open it in Excel and that could be causing issues during the import.
So if you follow those instructions above you should be able to make it work. Pipes seem to work best both in the CSV and via the Feeds Tamper configuration for your mapping.
Hope this helps!
Best-
Trevor
Comment #142
raveman CreditAttribution: raveman commentedSo, I need to set CSV separator to '|' to work ? Or i need to use | in my field ?
id;field1;field2;field3a|field3b|field3c|field3d;
?
And, do I need to configure feed_tamper to explode field3X ?
I can't get working import with multiple node references :(
Thanx for any help
Comment #143
liquidcms CreditAttribution: liquidcms commentednvm..
Comment #144
liquidcms CreditAttribution: liquidcms commented