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; }
添付 | サイズ |
---|---|
feeds_entity_processor-1033202-217.patch_.txt (16.03 KB) | 16.03 KB |
/** * 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; }
添付 | サイズ |
---|---|
view_widget_custom.zip (2.03 KB) | 2.03 KB |
/** * Implements hook_field_widget_form_alter(). */ function YOUR_MODULE_NAME_field_widget_form_alter(&$element, &$form_state, $context) { if( !isset( $element['#theme'] ) || $element['#theme']!== 'entityreference_view_widget_widget' ) return ; // change target element from '#field_suffix' to '#title' $index = 0; while( isset($element[$index] ) ){ if( isset( $element[$index]['target_id']['#field_suffix'] ) ){ $title = $element[$index]['target_id']['#field_suffix'] ; unset( $element[$index]['target_id']['#field_suffix'] ) ; $element[$index]['target_id']['#title'] = $title ; } $index ++ ; } }
添付 | サイズ |
---|---|
view_widget_custom.zip (2.03 KB) | 2.03 KB |
/** * Implements hook_field_widget_form_alter(). */ function YOUR_MODULE_NAME_field_widget_form_alter(&$element, &$form_state, $context) { if( !isset( $element['#theme'] ) || $element['#theme']!== 'entityreference_view_widget_widget' ) return ; // change target element from '#field_suffix' to '#title' $index = 0; while( isset($element[$index] ) ){ if( isset( $element[$index]['target_id']['#field_suffix'] ) ){ $title = $element[$index]['target_id']['#field_suffix'] ; unset( $element[$index]['target_id']['#field_suffix'] ) ; $element[$index]['target_id']['#title'] = $title ; } $index ++ ; } }
添付 | サイズ |
---|---|
view_widget_custom.zip (2.03 KB) | 2.03 KB |
/** * Implements hook_field_widget_form_alter(). */ function YOUR_MODULE_NAME_field_widget_form_alter(&$element, &$form_state, $context) { if( !isset( $element['#theme'] ) || $element['#theme']!== 'entityreference_view_widget_widget' ) return ; // change target element from '#field_suffix' to '#title' $index = 0; while( isset($element[$index] ) ){ if( isset( $element[$index]['target_id']['#field_suffix'] ) ){ $title = $element[$index]['target_id']['#field_suffix'] ; unset( $element[$index]['target_id']['#field_suffix'] ) ; $element[$index]['target_id']['#title'] = $title ; } $index ++ ; } }
添付 | サイズ |
---|---|
view_widget_custom.zip (2.03 KB) | 2.03 KB |
/** * Implements hook_field_widget_form_alter(). */ function YOUR_MODULE_NAME_field_widget_form_alter(&$element, &$form_state, $context) { if( !isset( $element['#theme'] ) || $element['#theme']!== 'entityreference_view_widget_widget' ) return ; // change target element from '#field_suffix' to '#title' $index = 0; while( isset($element[$index] ) ){ if( isset( $element[$index]['target_id']['#field_suffix'] ) ){ $title = $element[$index]['target_id']['#field_suffix'] ; unset( $element[$index]['target_id']['#field_suffix'] ) ; $element[$index]['target_id']['#title'] = $title ; } $index ++ ; } }
添付 | サイズ |
---|---|
view_widget_custom.zip (2.03 KB) | 2.03 KB |
/** * Implements hook_field_widget_form_alter(). */ function YOUR_MODULE_NAME_field_widget_form_alter(&$element, &$form_state, $context) { if( !isset( $element['#theme'] ) || $element['#theme']!== 'entityreference_view_widget_widget' ) return ; // change target element from '#field_suffix' to '#title' $index = 0; while( isset($element[$index] ) ){ if( isset( $element[$index]['target_id']['#field_suffix'] ) ){ $title = $element[$index]['target_id']['#field_suffix'] ; unset( $element[$index]['target_id']['#field_suffix'] ) ; $element[$index]['target_id']['#title'] = $title ; } $index ++ ; } }
添付 | サイズ |
---|---|
view_widget_custom.zip (2.03 KB) | 2.03 KB |
/** * Implements hook_field_widget_form_alter(). */ function YOUR_MODULE_NAME_field_widget_form_alter(&$element, &$form_state, $context) { if( !isset( $element['#theme'] ) || $element['#theme']!== 'entityreference_view_widget_widget' ) return ; // change target element from '#field_suffix' to '#title' $index = 0; while( isset($element[$index] ) ){ if( isset( $element[$index]['target_id']['#field_suffix'] ) ){ $title = $element[$index]['target_id']['#field_suffix'] ; unset( $element[$index]['target_id']['#field_suffix'] ) ; $element[$index]['target_id']['#title'] = $title ; } $index ++ ; } }
添付 | サイズ |
---|---|
view_widget_custom.zip (2.03 KB) | 2.03 KB |
/** * Implements hook_field_widget_form_alter(). */ function YOUR_MODULE_NAME_field_widget_form_alter(&$element, &$form_state, $context) { if( !isset( $element['#theme'] ) || $element['#theme']!== 'entityreference_view_widget_widget' ) return ; // change target element from '#field_suffix' to '#title' $index = 0; while( isset($element[$index] ) ){ if( isset( $element[$index]['target_id']['#field_suffix'] ) ){ $title = $element[$index]['target_id']['#field_suffix'] ; unset( $element[$index]['target_id']['#field_suffix'] ) ; $element[$index]['target_id']['#title'] = $title ; } $index ++ ; } }
添付 | サイズ |
---|---|
view_widget_custom.zip (2.03 KB) | 2.03 KB |
/** * Implements hook_field_widget_form_alter(). */ function YOUR_MODULE_NAME_field_widget_form_alter(&$element, &$form_state, $context) { if( !isset( $element['#theme'] ) || $element['#theme']!== 'entityreference_view_widget_widget' ) return ; // change target element from '#field_suffix' to '#title' $index = 0; while( isset($element[$index] ) ){ if( isset( $element[$index]['target_id']['#field_suffix'] ) ){ $title = $element[$index]['target_id']['#field_suffix'] ; unset( $element[$index]['target_id']['#field_suffix'] ) ; $element[$index]['target_id']['#title'] = $title ; } $index ++ ; } }
添付 | サイズ |
---|---|
view_widget_custom.zip (2.03 KB) | 2.03 KB |
/** * Implements hook_field_widget_form_alter(). */ function YOUR_MODULE_NAME_field_widget_form_alter(&$element, &$form_state, $context) { if( !isset( $element['#theme'] ) || $element['#theme']!== 'entityreference_view_widget_widget' ) return ; // change target element from '#field_suffix' to '#title' $index = 0; while( isset($element[$index] ) ){ if( isset( $element[$index]['target_id']['#field_suffix'] ) ){ $title = $element[$index]['target_id']['#field_suffix'] ; unset( $element[$index]['target_id']['#field_suffix'] ) ; $element[$index]['target_id']['#title'] = $title ; } $index ++ ; } }
添付 | サイズ |
---|---|
view_widget_custom.zip (2.03 KB) | 2.03 KB |
/** * Implements hook_field_widget_form_alter(). */ function YOUR_MODULE_NAME_field_widget_form_alter(&$element, &$form_state, $context) { if( !isset( $element['#theme'] ) || $element['#theme']!== 'entityreference_view_widget_widget' ) return ; // change target element from '#field_suffix' to '#title' $index = 0; while( isset($element[$index] ) ){ if( isset( $element[$index]['target_id']['#field_suffix'] ) ){ $title = $element[$index]['target_id']['#field_suffix'] ; unset( $element[$index]['target_id']['#field_suffix'] ) ; $element[$index]['target_id']['#title'] = $title ; } $index ++ ; } }