Thursday 26 February 2009 6:36:43 am
Hi again, finally, I can remove the relation_item in the database, but the new content of the "data_text" attribute of the $contentObjectAttribute does not appear on the site (even after emptying cache) ; so that I have to create a new version from the admin interface to have the attribute content displayed.
I tried to complete the script with the "fixRelatedObjectItem" function, without success. Here's my code :
else if ( $http->hasPostVariable( "removeambiance" ) )
{
$object_membre_origine_id = $http->postVariable( 'object_membre_origine_id' );
$object_ambiance_cible_id = $http->postVariable( 'object_ambiance_cible_id' );
$redirect_node_id = $http->postVariable( 'redirect_node_id' );
$object_membre_origine = eZContentObject::fetch( $object_membre_origine_id );
$contentObjectVersion = $object_membre_origine->version( $object_membre_origine->attribute( 'current_version' ) );
$contentObjectAttributes = $contentObjectVersion->contentObjectAttributes();
foreach ($contentObjectAttributes as $contentObjectAttribute)
{
$contentClassAttribute = $contentObjectAttribute->attribute( 'contentclass_attribute' );
if ($contentClassAttribute->attribute("identifier") == "ambiances")
{
// $priority = '1';
$content = eZObjectRelationListType::removeRelatedObjectItem( $contentObjectAttribute, $object_ambiance_cible_id );
$contentObjectAttribute->setContent( $content );
$contentObjectAttribute->store();
// $priority++;
// test adding the "fix"
eZObjectRelationListType::fixRelatedObjectItem ( $contentObjectAttribute, $object_ambiance_cible_id, 'remove' );
}
}
return $module->redirectToView( 'view', array( 'full', $redirect_node_id ) ) ;
}
I can't figure out how this script can set the good value for the attribute in the database while preventing any or the related_items to display...? This might be related to these debug errors, which I unfortunately don't understand :
Strict: PHP Feb 26 2009 12:11:37
Non-static method eZObjectRelationListType::removeRelatedObjectItem() should not be called statically, assuming $this from incompatible context in C:\mysite\content\action.php on line 1622
Strict: PHP Feb 26 2009 12:11:37
Non-static method eZObjectRelationListType::storeObjectDOMDocument() should not be called statically, assuming $this from incompatible context in C:\mysite\kernel\classes\datatypes\ezobjectrelationlist\ezobjectrelationlisttype.php on line 1824
I'm kind of stuck at the very end of my project. Any help would then be greatly appreciated, even a bulk piece of code using the "removeRelatedObjectItem" function... Thanks in advance :-)
|