Closed (fixed)
Project:
Node factory
Version:
5.x-1.0-beta2
Component:
Miscellaneous
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
8 Jun 2008 at 21:05 UTC
Updated:
12 Dec 2010 at 22:28 UTC
Hi
I have been having a hard time with using this module because I don't know php or coding that well. The code below inserts the first letter of the text string into the database. So instead of 'x_location' and 'y_location', the values are 'x' and 'y'. The title comes up as it should.
$edit = node_factory_create_node( 'frame');
node_factory_set_value( $edit, 'title', 'frame_title');
node_factory_set_value( $edit, 'field_photo_x', 'x_location');
node_factory_set_value( $edit, 'field_photo_y', 'y_location');
node_factory_save_node( $edit);
I've also put these lines in the node_factory_set_value function to track $value which gives me the full string:
case 'number_integer':
if ( $field['multiple'] == 1) {
$edit[ $name]['keys'][] = $value;
}
else {
$edit[ $name]['key'] = $value;
echo $value;
}
return;
Is there something simple that I'm missing or am I just way out there in left field?
Please help.
Thanks
Ken
Comments
Comment #1
clemens.tolboomWhat cck field type is field_photo_x?
And why are you testing 'number_integer' for it? It's a string right?
Comment #2
SamRose commentedI ran into the same thing. Testing with some simple code:
Produces:
abstract:
L
given_name:
J
surname:
D
email:
e
Produces this error:
But no node content.
Of course, I am not claiming/assuming that something is wrong with Node Factory module :-)
But, just hoping I can learn more about how to call cck fields with this module. What are we missing here?
Comment #3
SamRose commentedI guess I also see right away that the second example is looking for an array, which does give me a clue there...(working out now)
Comment #4
SamRose commentedOk, so I do see that there should be an array when referencing cck, like this:
That makes sense.
Does this work for all cck types, then?
Comment #5
SamRose commented...although, another example from http://drupal.org/project/node_factory shows
Which of course is a cck field, but is not calling "node_factory_set_cck_value"
So, this is a wee bit confusing.
Comment #6
SamRose commentedUpdate:
Even if I use
Still only prints first letter of the string...
Comment #7
SamRose commentedFor anyone else troubled with this:
if the Drupal 5.x cck field is of type 'text':
* use "field_" prefix in node_factory_set_value
* format your array as $my_array[0]['value'] = $my_string;
This worked for me 100%
Comment #8
fraguas commentedWhat works for me: (for drupal 6)
node_factory_set_cck_value( $edit, 'field_myField', array(array( 'value' => 'It works!!!')));