eZ Community » Forums » Developer » Saving ezxmltext through ajax
expandshrink

Saving ezxmltext through ajax

Saving ezxmltext through ajax

Thursday 16 June 2011 9:37:16 pm - 1 reply

I tried to create something like an autosave feature for an ezxmltext, but I soon found out that it is not that easy to save the new data into the db in the correct format. I tried looking at ezxmltext datatype for getting help, but after several hours I gave up.

So... if I have in php the contents from a tiny mce editor and the contentObjectAttribute, how can I save them into the database in the right format?

What I did was either stripping the images or a lot of other things that were not right.

 

Oh, and just as a note: something strange happened, when trying to add images to the xml text I was getting some errors (like 'ez publish "A file is required for upload, no file were found.  No HTTP file found, cannot fetch uploaded file.') . Trying to find out the problems origins, without changing anything, it magically solved by itself after several tries and checking this on another ez publish install on the same server... Unfortunately, I cannot reproduce it.

PS: The redirection system is not good when using multiple tabs on the same ez publish installation. Maybe it should use post variables instead of cookies? I believe I should post this in the issues tracker.

Modified on Thursday 16 June 2011 9:40:21 pm by Sao Tavi

Thursday 16 June 2011 11:54:24 pm

With a little bit of help, I found the answer eventually. It seems that I needed to use the parser from ezoe, it works with no problems now.

Here is the code used:

 

                $parser = new eZOEInputParser( );
                $parser->setParseLineBreaks( true );
                 
                if (!$document = $parser->process( $http->postVariable('val') ))
                    return 'failed to parse';
                 
                // Create XML structure
                $xmlString = eZXMLTextType::domString( $document );              

                $options['description']->setAttribute('data_text', $xmlString);
                $options['description']->store();

Modified on Monday 20 June 2011 2:17:24 pm by Sao Tavi

expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from