|
Mercredi 11 Juin 2008 5:48:50 pm
Re: createAndPublishObject() et champs de type xmlblock
Bonsoir,
En effet il faut transformer ton texte en xml comprehensible pour ezpublish .. bon je vais te donner une partie du code que j utilise pour le faire 
//fetch
$testnode = eZFunctionHandler::execute( 'content', 'node', array( 'node_id' => $obj->attribute('main_node_id')));
$testobject =& $testnode->object();
$parser = new eZSimplifiedXMLInputParser( $testobject->attribute( 'id' ), true);
$parser->setParseLineBreaks( true );
$texte = $rows[$i][$value2];
$txt_ini = $texte;
$texte = nettoyage($texte);
$doc = $parser->process($texte);
// Creation de la structure xml
if(!is_object($doc))
{
echo "\r\nno dom document returned by xml parser\r\n";
$errors = $parser->getMessages();
foreach ( $errors as $error )
{
echo '* ' . $error . "\r\n";
}
echo $txt_ini;
echo "###################";
echo $texte;
echo "@@@@@@@@@@@@@@@@@@@";
echo string_convert($texte);
}
$xmlstring = eZXMLTextType::domString( $doc );
foreach( $testobject->contentObjectAttributes() as $contentObjectAttribute )
{
if(isset($xmlstring) && $xmlstring!=""
{
if( array_search($contentObjectAttribute->attribute( 'contentclass_attribute_identifier' ),$valid)!==FALSE)
{
$contentObjectAttribute->setAttribute( 'data_text', $xmlstring );
$contentObjectAttribute->store();
}
}
}
bon il y a des lignes que tu peux supprimer mais l idee est là.. en gros tu crees ton objet sans remplir les champs xml
tu recuperes l id de l objet que tu viens de creer
et via le code tu remplis les champs xml 
(la fonction nettoyage verifie que mes balises html soit correct.. si tu as un texte du type <p><u>texte </p> ezpublish ne va pas du tout aimer )
Si besoin de plus d aide contacte moi par mail : vincent.royol@gmail.com
A+
|