Carlos Revillo
|
Friday 16 June 2006 1:55:00 am
Hi. I've developed an extension to insert content in Ez Content Tree. In my site i have two siteaccess, spanish and english. I want to add content in these two languages from my php script. Right now, i can add spanish content, but i don't know how to add english content... For adding content, i'm using somethin like
$user_id = 14;
$parentNodeID=365;
$ClassID = 60;
$class =& eZContentClass::fetch( $ClassID );
$contentObject =& $class->instantiate( $userID, 1 );
$contentObject->setAttribute( 'name', "Objeto ");
$contentObjectID = $contentObject->attribute( 'id' );
$nodeAssignment =& eZNodeAssignment::create( array(
'contentobject_id' => $contentObject->attribute( 'id' ),
'contentobject_version' => $contentObject->attribute( 'current_version' ),
'parent_node' => $parentNodeID,
'sort_field' => 8,
'sort_order' => 1,
'is_main' => 1
)
);
$nodeAssignment->store();
$version =& $contentObject->version( 1 );
$version->setAttribute( 'status', EZ_VERSION_STATUS_DRAFT );
$version->store();
$contentObjectAttributes =& $version->contentObjectAttributes();
$contentObjectAttributes[0]->setAttribute( 'data_text', $codigo);
$contentObjectAttributes[0]->store();
$contentObjectAttributes[1]->setAttribute( 'data_text', $http->sessionVariable("p_nombre"));
$contentObject->store();
$operationResult = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $contentObjectID,
'version' => 1 ) );
But, as i said before, i only can add spanish version of that content. How can this script be modified so i can add english content two? thanks.
|
Kristof Coomans
|
Saturday 17 June 2006 1:55:29 am
After publishing the Spanish version, you can create a new version with an English translation:
$version = $obj->createNewVersionIn( $selectedEditLanguage );
$version->setAttribute( 'status', EZ_VERSION_STATUS_DRAFT );
$version->store();
$selectedEditLanguage is in your case "eng-GB". Now fill the attributes of this new version and publish it.
independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org
|
Martin Jerie
|
Friday 27 October 2006 2:10:01 am
Please can you show me rest of the code for publish translation Because when i use code from Carlos example:
$operationResult = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $contentObjectID, 'version' => 1 ) );
translation is only draft - how to publish it? Martin
|
|
Tuesday 23 October 2007 7:38:29 pm
Hi.
I use V 3.10 and "createNewVersionIn" works fine for one additional language. If I use main language and 2 additional languages ($a and $b):
// part A
$version = $obj->createNewVersionIn( $a );
$version->setAttribute( 'status', EZ_VERSION_STATUS_DRAFT );
$version->store();
...
// part B
$version = $obj->createNewVersionIn( $b );
$version->setAttribute( 'status', EZ_VERSION_STATUS_DRAFT );
$version->store();
part B always override part A.
|