1

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?

1 Answer 1

0

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'])),
            );
        }
    }
}
?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.