Share » Forums » Developer » Wanted: documentation on creating...

Wanted: documentation on creating contentObjects from scratch

Wanted: documentation on creating contentObjects from scratch

Tuesday 06 May 2003 8:22:27 am - 2 replies

Author Message

Paul Borgermans

Tuesday 06 May 2003 9:19:17 am

Gabriel,

I use the following source to study this. Maybe it helps you too:

http://zev.ez.no/svn/nextgen/trunk/scrap/rotaryimport.php

I agree on your request for better docs, which is one of the priorities of the ez team now.

Paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Gabriel Ambuehl

Friday 09 May 2003 8:40:36 am

Ok, so I have:
----------
$class =& eZContentClass::fetch( 28 );
// Create object by userid in sectionid
$contentObject =& $class->instantiate( $userID, $sectionID );

$nodeAssignment =& eZNodeAssignment::create( array(
'contentobject_id' => $contentObject->attribute( 'id' ),
'contentobject_version' => $contentObject->attribute( 'current_version' ),
'parent_node' => 1,
'is_main' => 1
)
);

$version =& $contentObject->version( 1 );
$contentObjectAttributes =& $version->contentObjectAttributes();

$contentObjectAttributes[0]->setContent( $structure->headers['from'] );
$contentObjectAttributes[0]->store();

$version->setAttribute( 'modified', eZDateTime::currentTimeStamp() );
$version->setAttribute( 'status', EZ_VERSION_STATUS_DRAFT );
$version->setAttribute( 'name', $name );

$version->store();
$contentObject->store();
$nodeAssignment->store();

$operationResult = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $contentObject->attribute( 'id' ), 'version' => 1 ) );

----------

But it doesn't quite work. I'd figure that the content object should be turning up in the root node but it won't (but it DOES get added to the db)

Visit http://triligon.org

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu