AnswerBun.com

Custom Field Type is missing in Feeds Importer

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?

One Answer

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

Add your own answers!

Related Questions

Social Media Embed Problems With the URL Embed module

0  Asked on November 30, 2021 by mckinzie25

 

Contextual links for node blocks

3  Asked on November 28, 2021

   

Set node to flagged by default

1  Asked on November 28, 2021 by andrew-morris

     

How do I replace drush_set_error()?

1  Asked on November 28, 2021

   

Get file ID and path to use in View template

1  Asked on November 25, 2021 by srodrig

         

How to use drupal_add_library with a module?

2  Asked on November 25, 2021

   

Ajax Form Not Working in some Some Regions

2  Asked on November 23, 2021 by sandesh-yadav

     

Facebook Album fetcher

1  Asked on November 23, 2021 by rajat-goyal

 

Condition on current moderation state

2  Asked on November 23, 2021 by paul-cappucci

   

how to apply a css code for a specific screen size

1  Asked on November 23, 2021 by coding-mv

 

hook_entity_predelete never called

0  Asked on November 23, 2021

   

User reference and Views 3 and Panels 3

1  Asked on November 21, 2021

     

MetaTag with JSON API won’t serialize

2  Asked on November 21, 2021 by johnventions

   

How to disable Rich Text Editor in image field caption ?

1  Asked on November 19, 2021 by lee-woodman

   

search block form not accepting special characters in drupal 7

1  Asked on November 19, 2021 by blueztechz

   

Unknown engine type outputformat

1  Asked on November 19, 2021 by gilles9999

     

Ask a Question

Get help from others!

© 2023 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP