Wednesday 20 October 2004 3:33:25 am
Paul, Here again (sorry, I posted to the other forum, because I had understood you wrong) Bringing the piece of code from http://ez.no/community/forum/developer/importing_update_entry_if_it_already_exists</code> here : I perfectly understand that I will need to change the code to use with my own content objects, but I would like to confirm if all of the main steps are here : 1) Fetching the class id of the content object to be created
$myClassID = eZContentClass::fetch( $myClassID );
2) Instantiating the content object
$myContentObject =& $class->instantiate( $myUserCreatorID, $myDefaultSectionID, false);
// what does mean the third parameter set to false?
3) Assign the new content object to the node tree
$nodeAssignment =& eZNodeAssignment::create( array(
'contentobject_id' => $mycontentObject->attribute( 'id' ),
'contentobject_version' => 1,
'parent_node' => $defaultUserPlacement,
'is_main' => 1
)
);
$nodeAssignment->store();
4) Set members attributes
$myContentObjectAttributes =& $myContentObject->attribute('data_map');
$myFirstAttribute = $myContentObjectAttributes['my_first_attribute'];
$mySecondAttribute = $myContentObjectAttributes['my_second_attribute'];
5) Set and store each attribute
$myFirstNameAttribute->setAttribute("data_text", "My First Attribute data"); $myFirstNameAttribute->store();
$mySecondNameAttribute->setAttribute("data_text", "My Second Attribute data"); $myLastNameAttribute->store();
6) Publish the object.
$operationResult = eZOperationHandler::execute( 'content',
'publish',
array( 'object_id' => $myContentObject->attribute( 'id' ),
'version' => $myContentObject->attribute('current_version' ) ) );
have I missed any important and basic step here ?
Lazaro
http://www.mzbusiness.com
|