Drupal Answers Asked on February 11, 2021
I’ve got a problem with feeds importer. I’ve created a custom field type, and added a field with this field type to my content. If I try to import data via feeds importer, in mapping, this field is missing. Do I have to tell my custom field type that it is useable within feeds-importer?
You might need to create a target for your custom field type with the help of hook_feeds_processor_targets_alter and here is a code sample for doing so:
<?php
function MYMODULE_feeds_processor_targets_alter(&$targets, $entity_type, $bundle_name)
{
foreach (field_info_instances($entity_type, $bundle_name) as $name => $instance)
{
$info = field_info_field($name);
unset($callback);
if ($info['type']=='MYFIELDTYPE1')
{
//The callback for this field type goes here.
$callback = 'TARGET_SETTER_FOR_MYFIELDTYPE1';
}
if ($info['type']=='MYFIELDTYPE2')
{
//The callback for this field type goes here.
$callback = 'TARGET_SETTER_FOR_MYFIELDTYPE2';
}
//Add cases for each field type here
//...
if (isset($callback))
{
$targets[$name] =array(
'name'=>check_plain($instance['label']),
'callback' => $callback,
'description' => t('The @label field of the node.', array('@label' => $instance['label'])),
);
}
}
}
?>
Answered by Pravin Ajaaz on February 11, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP