csv Import/Export Pick

0

I tried to get an answer to this issue before but it may have been lost among the other answers. I created a pod with PICK relationships and then ran the API import/export methods by a) entering a single record into the pod template, b) exporting the data via API, c) changing the data by appending "2" to non-PICK data in the csv, and c) re-importing the data using the csv file . Here's the data I re-imported via file.csv.

name,r_subtitle,author,r_summary,r_call_id,level,topic,type,format,r_quantity,r_copyright,r_slug,r_number,r_topic_code,author_code,reprint,author_last
"Resource Title2","Subtitle2 of Resource","First Names of authors","This is a summary text field for the resource.",array(05ATF),array(High),array(Animal),array(Bibliography),array(Book),1.00,2000,,123,array(ANL),"Author Code",1,"Last names of authors"

The result displayed multiple "Warning: implode() [function.implode]: Invalid arguments passed in /home1/classrp1/public_html/wp-content/plugins/pods/classes/PodAPI.php on line 1469" messages. I noted the number of errors matched the number of fields with PICK arrays.

Any ideas of what's going here? Thanks in advance.

asked Sep 11 '10 at 8:42

lawrence.siulagi

1

add comment
enter at least 15 characters

3 Answers

0

The problem is caused by line #1456 in PodAPI.php. It sets the variable $field_value to a string value, however, it later sets it as an array if it needs to be one. PHP is giving back that error because it doesn't like that you're trying to change what that variable was initially set up to hold. Also, when putting my PICK column values into my csv I didn't put them in array(value) format. I simply just have the value typed out.

To fix this, inside the if loop on lines 1463 and 1466 where it sets $field_value[] = to something, change the name of that variable to something else. Then, on line 1469 inside the implode function set the variable there to match the array you just created. Below is a sample of the function i changed on my system to get it working for me.

            if (null != $field_value && false !== $field_value) {
                if ('pick' == $coltype || 'file' == $coltype) {
                    $field_values = is_array($field_value) ? $field_value : array($field_value);
                    echo "<pre>"; print_r($field_values); echo "</pre>";
                    foreach ($field_values as $key => $pick_title) {
                        if (is_int($pick_title) && false !== $numeric_mode) {
                            $field_value_array[] = $pick_title;
                        }
                        elseif (!empty($pick_values[$field_name][$pick_title])) {
                            $field_value_array[] = $pick_values[$field_name][$pick_title];
                        }
                    }
                    $field_value = implode(',',$field_value_array);
                }
                $columns[$field_name] = mysql_real_escape_string(trim($field_value));
            }

answered Sep 26 '10 at 9:04

ryanmarc

1

edited Sep 26 '10 at 9:07

add comment
enter at least 15 characters
0

This was actually fixed in Pods 1.9.2

answered Sep 27 '10 at 5:44

sc0ttkclark

2936

add comment
enter at least 15 characters
0

i'll be damned.. i was running 1.9.1. thanks

answered Sep 28 '10 at 1:10

ryanmarc

1

add comment
enter at least 15 characters