Home » Topics » Pods 1.x » Importing pod content not saving multiple pick data
Importing pod content not saving multiple pick data
This topic contains 4 replies, has 2 voices, and was last updated by macnikki 1 year, 11 months ago.
-
AuthorPosts
-
June 2, 2011 at 7:24 am #165762
I am doing an import at the bottom of my pod page, after creating php variables with the data to save. The import works perfectly if I manually put the multiple pick fields into the array. It also works perfectly on importing the php variable values for text and single pick items. There is no error, it saves the record but just does not save the multiple field values. This is my import code:
$textfield="Value1";
$single_pick="Value2";
$array_field="’multiple_pick’ => array(‘option1′,’option2′)";$data = array(
0 => array(
‘textfield’ => "$Value1",
‘single_pick => "$Value2",
"$array_field"
)
);
$pods = new PodAPI(‘podname’, ‘php’);
$pods->import($data);I have tried doing the $array_field variable with just the array values like this:
$array_field="(‘option1′,’option2′)";
$data = array(
0 => array(
‘textfield’ => "$Value1",
‘single_pick’ => "$Value2",
‘multiple_pick’ => "$array_field"
)
);but this also does not work.
Finally I tried this:
$array_field="’option1′,’option2′";
$data = array(
0 => array(
‘textfield1′ => "$Value1",
‘single_pick’ => "$Value02",
‘multiple_pick’ => array ("$array_field")
)
);But this does not save anything and gives an error saying the multiple_pick field is empty.
Any suggestions? Is it possible to import multiple pick field values using a php variable rather than having to import them manually? I could write this as SQL no problem but I cannot see where to store the pick values on the database.
June 2, 2011 at 11:42 am #165763June 2, 2011 at 3:50 pm #165764Thanks Chris. There is an extra bracket at the end of your example – is this supposed to be there or is there meant to be another one to balance it out somewhere?
I tried this:
$var1=’name’;
$var2=’name indo’;
$var3=’Education,Design’;
$data = array(‘name’ => $var1, ‘name_indo’ => $var2, ‘main_activities’ => $var3);I also tried the same setting of the variables with:
$data = array(‘name’ => $var1, ‘name_indo’ => $var2, ‘main_activities’ => array($var3));
In both cases I still got the message that the main_focus field was empty and it did not save it (This message at the bottom of my thankyou page: Main Activities is empty). It works perfectly if $var3=’Education’ but I need to be able to save multiple pick values for $var3. Could you help me on the correct syntax for $var3 if there is more than one value?
Thanks.
June 2, 2011 at 4:29 pm #165765@nikki:
The extra bracket was a mistake. I lifted the code from your example and didn’t edit that part out.
You need to read the arrays part of the PHP manual. In your first example above $var3 is a string, not an array. In the second example, $var3 is an array containing one string.
You need to declare it like this:
Or this:
Or this:
June 4, 2011 at 2:26 am #165766Thank you so much Chris – I don’t know why I was having such a duh moment with this. Your examples were great and now it is working perfectly! The Bali Clean and Green campaign is eternally grateful to you! We now have a fully bilingual site able to document all the eco projects happening on the island. Fantastic!
-
AuthorPosts
You must be logged in to reply to this topic.