eZ Community » Forums » Developer » Object creation and xmlblock
expandshrink

Object creation and xmlblock

Object creation and xmlblock

Thursday 02 May 2013 1:57:51 pm - 4 replies

Hi everyone !

I'm currently trying to import RSS feeds into my eZPublish 2013.4 to create content. Everything works fine, except for my XMLBlocks field, which are empty.

I first tried to import them directly, as I did for text lines, but of course, xml is expected, so I parsed them using ezSimplifiedXMLInputParser, everything works as expected, no errors, and a nice xml string is returned (which I send to eZXMLTextType::domString).

However, when I create the content, I get the following notice : Undefined offset in ContentService at line 1867.

After that, when I put a var_dump on the content, where there shoud be the xmlblock attribute, I just get a field with empty fieldIdentifier, which contains an empty DOMDocument Object.

Any idea what I could have done bad or forgot please ?

Thank you guys happy.gif Emoticon

Friday 24 May 2013 2:43:16 pm

Hi,

Maybe you've forgotten to use one of these functions ?

$text = "Lorem ipsum ..."
 
$parser = new eZSimplifiedXMLInputParser();
$parser->setParseLineBreaks(true);
$xmlDocument = $parser->process($text);
$xml = eZXMLTextType::domString($xmlDocument);
 
$params = array(
    'parent_node_id' => 2,
    'creator_id' => false,
    'class_identifier' => 'article',
    'attributes' => array('text' => $xml)
);
 
$object = eZContentFunctions::createAndPublishObject($params);

If it helps...

Vincent

Modified on Friday 24 May 2013 2:43:59 pm by Vincent Robic

Saturday 25 May 2013 6:07:37 am

Hi,

I also had a similar issue this past week. I've been making ajax based editing for a website and had issues with parsing the TinyMCE xml into the xml block when I did some reading of the eZ OE source code I found a different parser that solved my problem. It may help you out.

My code looked like:

 //i'm pulling it from an input field for this example.
$bodyText = $http->variable($inputField);
 
//Create parser object
$parser = new eZOEInputParser();
 
//Process the input text and return it as xml for publishing
$document = $parser->process( $bodyText );
 
//Add to attribute list for updating.
$attributeList = array();
$attributeList['xml_block_attribute'] = eZXMLTextType::domString( $document );
 
//continue with updating / creating node code.

It's updating an object and not creating one but the parsing of xml you might find helpful.

Not sure if it will be of any help. But if you're not getting anywhere with

eZSimplifiedXMLInputParser()

then it may be another avenue you can look at.

Modified on Saturday 25 May 2013 6:08:18 am by Daniel Clements

Monday 27 May 2013 3:52:06 pm

Hi !

Thanks guys, after hours of searching, I finally abandonned the idea of getting back my text formatting, so I imput text stripped from tags, to avoid errors from the parser. It's too bad but I can't get it working another way sad.gif Emoticon

Thursday 30 May 2013 1:55:10 pm

 

 

> var_dump on the content, where there shoud be the xmlblock attribute, I just get a field with empty fieldIdentifier, which contains an empty DOMDocument Object.

 

 

Bit late now, but are you sure the DOMDocument Object was empty?

You can't var_dump a DOMDocument object in < PHP 5.4.1 (It's a bug https://bugs.php.net/bug.php?id=48527).

You have to use something like:

 $var = $dom->saveHTML()

or

 $var = $dom->saveHTML( $element )

Modified on Thursday 30 May 2013 1:56:59 pm by Gareth Arnott

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from