eZpedia : The Free eZ Publish CMS Documentation Encyclopedia

Snippet: PHP Snippet Creating new content object versions

This is compatible with eZ Publish 4.

You can update objects by creating new version and publish the new version.

The code

Known variables

  • $object, instance of class eZContentObject

Sample

$newVersion = $object->createNewVersion();
 
$newData = $object->fetchDataMap( $newVersion->attribute( 'version' ) );
 
// change attributes of new version here, by using $newData data map
 
$result = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $object->attribute( 'id' ), 'version' => $newVersion->attribute( 'version' ) ) );

Article provided by eZpedia

All text is available under the terms of the GNU Free Documentation License

Powered by eZ Publish Community Project 4.2011

Hosted by Swiss eZ Publish partner YMC