Copy Source | Copy HTML function my_module_node_import_fields( $type ) { if (_uc_product_node_import_is_product( $type )) { $fields = array ( 'my_field_0' => 'MY FIELD 0' , 'my_field_1' => 'MY FIELD 1' , ... 'my_field_n' => 'MY FIELD N' , 'my_image_filepath' => 'MY Image filepath' , ); return $fields ; }
Copy Source | Copy HTML function my_module_node_import_fields( $type ) { if (_uc_product_node_import_is_product( $type )) { $fields = array ( 'my_field_0' => 'MY FIELD 0' , 'my_field_1' => 'MY FIELD 1' , ... 'my_field_n' => 'MY FIELD N' , 'my_image_filepath' => 'MY Image filepath' , ); return $fields ; }
Copy Source | Copy HTML function my_module_node_import_fields( $type ) { if (_uc_product_node_import_is_product( $type )) { $fields = array ( 'my_field_0' => 'MY FIELD 0' , 'my_field_1' => 'MY FIELD 1' , ... 'my_field_n' => 'MY FIELD N' , 'my_image_filepath' => 'MY Image filepath' , ); return $fields ; }
Copy Source | Copy HTML function my_module_node_import_fields( $type ) { if (_uc_product_node_import_is_product( $type )) { $fields = array ( 'my_field_0' => 'MY FIELD 0' , 'my_field_1' => 'MY FIELD 1' , ... 'my_field_n' => 'MY FIELD N' , 'my_image_filepath' => 'MY Image filepath' , ); return $fields ; }
Copy Source | Copy HTML function my_module_node_import_fields( $type ) { if (_uc_product_node_import_is_product( $type )) { $fields = array ( 'my_field_0' => 'MY FIELD 0' , 'my_field_1' => 'MY FIELD 1' , ... 'my_field_n' => 'MY FIELD N' , 'my_image_filepath' => 'MY Image filepath' , ); return $fields ; }
Copy Source | Copy HTML function my_module_node_import_fields( $type ) { if (_uc_product_node_import_is_product( $type )) { $fields = array ( 'my_field_0' => 'MY FIELD 0' , 'my_field_1' => 'MY FIELD 1' , ... 'my_field_n' => 'MY FIELD N' , 'my_image_filepath' => 'MY Image filepath' , ); return $fields ; }
Copy Source | Copy HTML function my_module_node_import_fields( $type ) { if (_uc_product_node_import_is_product( $type )) { $fields = array ( 'my_field_0' => 'MY FIELD 0' , 'my_field_1' => 'MY FIELD 1' , ... 'my_field_n' => 'MY FIELD N' , 'my_image_filepath' => 'MY Image filepath' , ); return $fields ; }
Copy Source | Copy HTML function my_module_node_import_fields( $type ) { if (_uc_product_node_import_is_product( $type )) { $fields = array ( 'my_field_0' => 'MY FIELD 0' , 'my_field_1' => 'MY FIELD 1' , ... 'my_field_n' => 'MY FIELD N' , 'my_image_filepath' => 'MY Image filepath' , ); return $fields ; }
Copy Source | Copy HTML function my_module_node_import_fields( $type ) { if (_uc_product_node_import_is_product( $type )) { $fields = array ( 'my_field_0' => 'MY FIELD 0' , 'my_field_1' => 'MY FIELD 1' , ... 'my_field_n' => 'MY FIELD N' , 'my_image_filepath' => 'MY Image filepath' , ); return $fields ; }
Copy Source | Copy HTML function my_module_node_import_fields( $type ) { if (_uc_product_node_import_is_product( $type )) { $fields = array ( 'my_field_0' => 'MY FIELD 0' , 'my_field_1' => 'MY FIELD 1' , ... 'my_field_n' => 'MY FIELD N' , 'my_image_filepath' => 'MY Image filepath' , ); return $fields ; }
Copy Source | Copy HTML function my_module_node_import_fields( $type ) { if (_uc_product_node_import_is_product( $type )) { $fields = array ( 'my_field_0' => 'MY FIELD 0' , 'my_field_1' => 'MY FIELD 1' , ... 'my_field_n' => 'MY FIELD N' , 'my_image_filepath' => 'MY Image filepath' , ); return $fields ; }
Copy Source | Copy HTML function my_module_node_import_fields( $type ) { if (_uc_product_node_import_is_product( $type )) { $fields = array ( 'my_field_0' => 'MY FIELD 0' , 'my_field_1' => 'MY FIELD 1' , ... 'my_field_n' => 'MY FIELD N' , 'my_image_filepath' => 'MY Image filepath' , ); return $fields ; }
Copy Source | Copy HTML
- function my_module_node_import_prepare (& $ node , $ preview = FALSE) {
- $ errors = array ();
- if (! isset ( $ node -> my_field_0) || empty ( $ node -> my_field_0)) {
- $ errors [] = t ( 'ERROR! on MY FIELD 0' );
- } else $ node -> field_0 = $ node -> my_field_0;
- if (! isset ( $ node -> my_field_1) || empty ( $ node -> my_field_1)) {
- $ errors [] = t ( 'ERROR! on MY FIELD 1' );
- } else $ node -> field_1 = $ node -> my_field_1;
- ...
- if (! isset ( $ node -> my_field_n) || empty ( $ node -> my_field_n)) {
- $ errors [] = t ( 'ERROR! on MY FIELD N' );
- } else $ node -> field_n = $ node -> my_field_n;
- return $ errors ;
- }
Copy Source | Copy HTML
- function _my_module_create_image_field ( $ filepath , $ nid ) {
- $ file_temp = file_get_contents ( $ filepath );
- $ file_temp = file_save_data ( $ file_temp , file_directory_path (). '/ images /' . basename ( $ filename ), FILE_EXISTS_RENAME);
- $ image_field [ '0' ] [ 'fid' ] = 'upload' ;
- $ image_field [ '0' ] [ 'title' ] = basename ( $ file_temp );
- $ image_field [ '0' ] [ 'nid' ] = $ nid ;
- $ image_field [ '0' ] [ 'filename' ] = basename ( $ file_temp );
- $ image_field [ '0' ] [ 'filepath' ] = $ file_temp ;
- $ image_field [ '0' ] [ 'filemime' ] = mime_content_type ( $ file_temp );
- $ image_field [ '0' ] [ 'filesize' ] = filesize ( $ file_temp );
- return $ image_field ;
- }
Copy Source | Copy HTML
- if (! $ preview ) {
- if ( isset ( $ node -> my_image_filepath)) {
- if (file_exists ( $ node -> naeyc_image_filepath)) {
- $ node -> field_image_cache = _my_module_create_image_field ( $ node -> my_image_filepath, $ node -> nid);
- } else $ errors [] = $ node -> my_image_filepath. t ( 'file is not exists.' );
- }
- }
Source: https://habr.com/ru/post/56666/
All Articles