Wednesday 14 October 2009 1:28:32 pm
Hello, In a content class, I have an ezkeyword field ('my_field') which Id like to update in PHP I use the usual fromString() function
$contentObjectAttributes = $contentObject->fetchAttributesByIdentifier(array('my_field'), $new_version_id, $languageCode);
foreach($contentObjectAttributes as $key => $contentObjectAttribute)
{
$contentObjectAttribute->fromString($my_new_value);
$contentObjectAttribute->store();
}
... which works fine when <b>$my_new_value</b> is not set to '' but it does not change anything when <b>$my_new_value</b> is empty I've had a look in <b>classes/datatypes/ezkeyword/ezkeywordtype.php</b> and I've found this circa line 285
function fromString( $contentObjectAttribute, $string )
{
if ( $string != '' )
{
$keyword = new eZKeyword();
$keyword->initializeKeyword( $string );
$contentObjectAttribute ->setContent( $keyword );
}
return true;
}
... which explains why nothing happens in my fromString when <b>$my_new_value</b> is empty So my question is : <b>how do I empty in PHP an ezkeyword field ?</b>
Thanks a lot in advance Benoit
|