Warning: substr() expects parameter 1 to be string, array given FeedsFetcherResult->sanitizeRaw() (/virtual/drills/public_html/drupal7/sites/all/modules/feeds/plugins/FeedsFetcher.inc ファイル 75行).
/** * Implements hook_feeds_processor_targets_alter(). */ function my_module_feeds_feeds_processor_targets_alter(array &$targets, $entity_type, $bundle) { if( $entity_type=="node"&&$bundle=="chinese_word"){ $field_info = field_info_instances("node", "chinese_word") ; if( array_key_exists('field_ch_word_sentences', $field_info ) && field_info_field( 'field_ch_word_sentences' )['type'] == "entityreference" ){ $targets["field_ch_word_sentences:drills_hander"] = array( 'name' => check_plain( $field_info['field_ch_word_sentences']['label'] ).t(' (Import multiple value instance field)'), 'callback' => 'drills_custom_feeds_set_target_entity_reference', 'description' => t('This filed for converting Chinese Examples to word reference only.Do not use it for other fields!!'), ); } } }
function drills_custom_feeds_set_target_entity_reference($source, &$entity, $target, $value, $mapping){ if (empty($value)) { return; } $target = str_replace(':drills_hander', '', $target); $query = db_query("select title, nid, CHAR_LENGTH(title) as char_num from node where title like '%".$value[0]."%' and type='example_sentences' order by char_num limit 100"); $sentences = $query->fetchAll(); $field = array(); foreach( $sentences as $i => $sentence ){ $field[LANGUAGE_NONE][$i]['target_id'] = $sentence->nid; } $entity->{$target} = $field; }