Forums / Developer / Inserting article through code problem / Comment41039
Paul Forsyth
Thursday 01 July 2004 12:47:50 am
Im not sure.
Here is the code I have for creating an folder Maybe you can adapt it instead of yours to see if it works?
function createFolderObject($user, $sectionID, $userNodeID=2, $folderTitle="No title") { $folderClassID=1; $class =& eZContentClass::fetch( $folderClassID ); $folderContentObject =& $class->instantiate( $user->id(), $sectionID ); // Create a node for the object in the tree. $nodeAssignment =& eZNodeAssignment::create( array( 'contentobject_id' => $folderContentObject->attribute( 'id' ), 'contentobject_version' => 1, 'parent_node' => $userNodeID, 'sort_field' => 2, //Published 'sort_order' => 1, //Descending 'is_main' => 1)); $nodeAssignment->store(); // Set a status for the content object version $folderContentObjectVersion =& $folderContentObject->version($folderContentObject->attribute( 'current_version' ) ); $folderContentObjectVersion->setAttribute( 'status', EZ_VERSION_STATUS_DRAFT); $folderContentObjectVersion->store(); // Set the title of the folder. $folderContentObjectAttributes =& $folderContentObjectVersion->contentObjectAttributes(); foreach ($folderContentObjectAttributes as $folderAttribute) { // Each attribute has an attribute called 'identifier' that identifies it. if ($folderAttribute->attribute("contentclass_attribute_identifier") == "title") { $folderAttribute->setAttribute("data_text",$folderTitle); $folderAttribute->store(); } } // Now publish the object. $operationResult = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $folderContentObject->attribute( 'id' ), 'version' => $folderContentObject->attribute('current_version' ) ) ); return; }
good luck!
paul
--http://www.visionwt.com