Friday 26 August 2005 1:16:15 am
Hi, Yes, this is possible programatically. To set the language as spanish, first do : eZContentObject::setDefaultLanguage( $language );
Then create your objetct (code taken from the forum, to create a folder) : $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;
Finally, reset the language to english : eZContentObject::setDefaultLanguage( $defaultLanguage );
Hope it helps. Lex
|