Forums / Developer / PHP content object translation
Joël LEGER
Wednesday 02 September 2009 8:58:11 am
Hi ,
i try to create an english version from my french content object.The only problem is when i try to set the attribute 'titre' fot the english version i got an error message : Undefined attribute 'titre', cannot set
here is the code :
$attributesData = array(); $attributesData['titre'] = 'TITRE EN FRE'; $params['attributes'] = $attributesData; $contentObject = eZContentFunctions::createAndPublishObject( $params ); $engVersion = $contentObject->createNewVersion( $contentObject->CurrentVersion, true, 'eng-US', 'fre-FR' ); $contentObjectAttributes = $engVersion->contentObjectAttributes(); $contentObjectAttributes[0]->setAttribute( 'titre', 'TITLE ENGLISH'); $contentObjectAttributes[0]->store(); eZOperationHandler::execute( 'content', 'publish', array('object_id' => $engVersion->ContentObjectID, 'version' => $engVersion->Version ) );
Carlos Revillo
Wednesday 02 September 2009 11:49:28 am
titre is the identifier for the attribute you have defined, but it's not part of the definition of the ezcontentobjectattribute_class.
supposing 'titre' as a ezstring datatype, you could try with
... $contentObjectAttributes[0]->setAttribute( 'data_text', 'TITLE ENGLISH'); $contentObjectAttributes[0]->store(); ...
hope it helps.
Thursday 03 September 2009 2:44:14 am
yes , works finethx