Tuesday 06 May 2003 6:36:00 am
Sorry for reposting, but it looks like nobody read old messages :(
I asked: I need to create new object instance and publish it in some existing node. Someone told me to use eZOperationHandler, but when I do so, I get this error: Warning: Invalid argument supplied for foreach() in c:\program files\ez systems\ezpublish\lib\ezutils\classes\ezmoduleoperationinfo.php on line 82 Is there some extra initialization necessary? Then somebody asked me for source, so here it is:
include_once( "kernel/classes/ezcontentclass.php" );
include_once( "kernel/classes/eznodeassignment.php"); include_once( "kernel/content/ezcontentoperationcollection.php" );
$node =& eZContentObjectTreeNode::fetch( 2 );
$parentContentObject =& $node->attribute( 'object' ); $sectionID = $parentContentObject->attribute( 'section_id' );
$class =& eZContentClass::fetch( 1 );
$contentObject =& $class->instantiate( 14, $sectionID ); $contentObject->setName( "MyNewFolder" ); $contentObject->store();
$nodeAssignment =& eZNodeAssignment::create( array(
'contentobject_id' => $contentObject->attribute( 'id' ),
'contentobject_version' => $contentObject->attribute( 'current_version' ),
'parent_node' => $node->attribute( 'node_id' ),
'is_main' => 1
)
);
$nodeAssignment->store();
include_once( 'lib/ezutils/classes/ezoperationhandler.php' );
$operationResult =& eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $contentObject->attribute( 'id' ), 'version' =>1 ) ); $contentObject =& eZContentObject::fetch( $contentObject->attribute( 'id' ) );
|