Forums / Developer / PHP : Copy relation list data from an object to another ?
Lex 007
Tuesday 05 April 2005 5:52:54 am
Hi,
I need to copy the content of a relation list of an object to another object in a cronjob.
Basically, I have a custom class folder with a relation list of users. I would like to have the same relation lists in the custom class files in that folder.
What I can currenly do is get the relation list $contentObjectAttributes of the folder and the file. I tried to copy directly the "data_text" from one to the other ... Nice try but it didn't work :(
Should I copy the relations items one by one ? If so, how to do it ?
Any hint is appreciated.
I hope this time my message will be heard :)
Lex
Tuesday 05 April 2005 5:59:19 am
Nevermind, I made it : stupid mistake.
I was using
->content()
instead of
->attribute("data_text")
Fabio Carissimi
Friday 30 June 2006 2:37:41 am
I use the method described in this post : http://ez.no/community/forum/developer/add_object_relation_attribute_type_within_a_php_script :
$content = $objectRelationListAttribute->content(); $priority = 1; foreach ( $objectsToRelate as $objectToRelate ) { $content['relation_list'][] = eZObjectRelationListType::appendObject( $objectToRelate->attribute( 'id' ), $priority, $objectRelationListAttribute ); $objectRelationListAttribute->setContent( $content ); $objectRelationListAttribute->store(); $priority++; }
but it does not work, can you describe in more details your method which is working ?
Thanks for help