Closed (fixed)
Project:
Feeds
Version:
6.x-1.0-beta5
Component:
Documentation
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
13 Sep 2010 at 16:00 UTC
Updated:
29 Nov 2012 at 02:31 UTC
Since there's no mapper, yet, for CCK or Domain Access, I worked around it. This is just to share what I did for people who need it right now and can't wait for a proper mapper. Once there are mappers for these, this code is not needed anymore.
/**
* Implementation of hook_nodeapi().
*/
function YOURMODULE_nodeapi(&$node, $op) {
switch ($op) {
case 'presave':
if ($node->type == 'YOUR_FEED_ITEM_NODE_TYPE') {
if (!empty($node->feeds_node_item->feed_nid)) {
$feed_node = node_load($node->feeds_node_item->feed_nid);
// Assign the domain of the feed node to the feed entry.
$node->domain_site = $feed_node->domain_site;
$node->domains = $feed_node->domains;
$node->subdomains = $feed_node->subdomains;
// Copy CCK field.
$node->field_CCK_FIELD_NAME = $feed_node->field_CCK_FIELD_NAME;
}
}
break;
}
}
Note that this must be done in presave. I could not get it to work in insert. Thanks to awolfey for pointing me at presave. :)
Michelle
Comments
Comment #1
ehudash commentedtesting...
Comment #2
ehudash commented@Michelle,
It worked like a charm for me.
This was very helpful!
Thanks!
Comment #3
ultimikeThanks for the code snippet - it works like a charm and is exactly what I was looking for!
-mike
Comment #4
alex_b commentedI've added a link to this guide to the FAQs http://drupal.org/node/836618#comment-3718366
Comment #6
dat deaf drupaler commentedThis is what I have been looking for. I apologize for being PHP illiterate.
I have created cck like this:
-celebrity profile page (not actual user profile)
-youtube video feed
-youtube video item (embedded)
-vimeo video feed
-vimeo video item (embedded)
I need to reference each videos automatically to celebrity profile cck through feed importer (is this also called inheriting?)... am trying to avoid creating dummy user accounts in order to use user ID for mapping in node processor. Seems like I have no lucks with using taxonomy so far. I am unsure if OG would be the answer to what I am trying to achieve?
Where do I add the codes posted above and how do I implement it?
Your help would be very much appreciated!
Comment #7
mstrelan commentedThank you so much Michelle, this is really helpful.
Comment #8
alan d. commentedFor D7 Domain Access. Domain sources node_load() has some tricks to it.
Comment #9
alan d. commentedAdded to docs - http://drupal.org/node/1853546