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.
This module worked great for me, except that it lacked the ability to map to CCK user reference fields. My company syndicates content between multiple online properties that it owns, and we need to match users coming in via a feed to local usernames. I wrote a mapper to do that, which I think could be included in the base distribution. It is attached. (The file should be named feedapi_mapper_userreference.inc but drupal.org does not accept .inc attachments)
Great job otherwise!
Comment | File | Size | Author |
---|---|---|---|
#5 | feedapi_mapper_userreference_for_beta14.patch | 2.05 KB | xmattus |
feedapi_mapper_userreference.patch | 1.99 KB | xmattus |
Comments
Comment #1
alex_b CreditAttribution: alex_b commentedI assume this patch applies to 6.x just as to beta 4.
Comment #2
xmattus CreditAttribution: xmattus commentedYes -- should be drop-and-go for any version.
Comment #3
TKS CreditAttribution: TKS commentedI get two iterations of the following warning when I drop this in as feedapi_mapper_userreference.inc:
Also, no user-reference option appears in the mapping-target pulldown.
I'm working with 6.x-1.0-beta12. Has something changed that requires a tweak to this .inc file? Or is $field_name variable -- which appears to be argument three on line 20 -- getting lost/not created/whatever elsewhere?
Happy to help test this addition -- and it'd be hugely useful to us! -- but I'm not sure where to start on fixing it.
Thanks
Comment #4
TKS CreditAttribution: TKS commentedUPDATE: Found mention of the same warning in http://drupal.org/node/224235, and -- per alex_b's suggestion in http://drupal.org/node/224235#comment-1734770 -- updated line 20 to match the example in feedapi_mapper.api.php to:
That gets rid of the warnings, but I still get no mapping option.
I'm guessing that there were API changes for the ($op == 'list') and/or ($op == 'map') portions too, but the logical changes there aren't nearly as obvious to me as line 20 was.
Comment #5
xmattus CreditAttribution: xmattus commentedUpon inspection, it seems a number of things about hook_feedapi_mapper have changed since beta4, including which parameters are passed in. I've retooled this mapper according to the main CCK mapper, so hopefully it works for you. Give it a whirl and let me know. (Same filename caveat applies -- it should be named feedapi_mapper_userreference.inc)
Comment #6
xmattus CreditAttribution: xmattus commentedComment #7
xmattus CreditAttribution: xmattus commentedTo clarify -- the function has to return some different stuff than it did before (namely an array rather than a boolean), so that explains you not seeing the user ref option.
Comment #8
TKS CreditAttribution: TKS commentedJust imported about 200 nodes as a test, and xmattus' revised .inc file (from comment #5) works flawlessly for me.
I was parsing in taxonomy terms -- we have an "author" vocabulary on our current D5 site, and are moving to a user-reference structure in D6. Those terms match usernames that we've already created in the D6 site.
One important thing to note: If there's a name that doesn't match -- for example, a former staffer for whom we neglected to create a user account on the new site -- the parser just ignores it. That's ideal, IMHO, as you don't want the mapping to choke on that, and it would be kinda crazy to attempt to create new accounts on the fly. I just mention it here for others who may want to use this.
Comment #9
xmattus CreditAttribution: xmattus commentedThat is correct, only extant users are matched by this mapper. It would actually not be terribly complex to create user accounts on the fly, but it requires some assumptions about what the default email address and such would be when it is not known otherwise. As this would be a more "extreme" behavior, I leave it to anyone who needs said behavior to customize further.
Comment #10
xmattus CreditAttribution: xmattus commented