eZ Community » Forums » Setup & design » remove return carriage from XML output
expandshrink

remove return carriage from XML output

remove return carriage from XML output

Monday 09 May 2011 11:07:10 am - 8 replies

Hi all,

I'm new in the eZpublish templating and I have a problem with a particular point!

I need to get the output of a XML bloc and send it to a javascript function, the problem is that javacript functions need to have their text arguments on the same line.

I use this method to get XML content :

data_map.myBlocXML.content.output.output_text

And when I add a image in the XML bloc, the output add some return carriage that make me this :

map.addPoint ("Siège social ", "",
  "<div><h1>Siège - Pc intevin</h1> <div class=\"infos\"><div class="">
  <div class="image_">...etc..."blunk.gif Emoticon;
   

So it break my javascript code!

I looking for a solution to remove these return carriage from output.

Thank's for answer,

JB Crestot

Monday 09 May 2011 12:07:04 pm

You should replace the newline character with an empty string of space. Since there's no string replace operator in eZP you'll have to use some extension that allows you to do it. For example wrap operator, which allows you to execute any PHP function. Or you can search on projects.ez.no for an extension that implements the string replace operator.

To eZ team: it's a real shame that eZP by default lacks such basic and essential operators for string manipulation.

Monday 09 May 2011 12:29:52 pm

Oh god...

Thank you Marko for your reply. wrap operator seems good.

Monday 09 May 2011 1:16:39 pm

Alternatively you could do

{def $outputXML = $myObject.data_map.myBlocXML.content.output.output_text|explode("\n"blunk.gif Emoticon|implode(" "blunk.gif Emoticon}

Not tested though...

Monday 09 May 2011 1:41:26 pm

Alternatively you could do

{def $outputXML = $myObject.data_map.myBlocXML.content.output.output_text|explode("\n"blunk.gif Emoticon|implode(" "blunk.gif Emoticon}

Not tested though...

Thank's for answer, but it doesn't work. sad.gif Emoticon

Edit: actually I made a mistake, something else break my code but this code work properly!

Thank you a lot.

Modified on Monday 09 May 2011 4:37:44 pm by Jean-Baptiste Crestot

Monday 09 May 2011 5:08:48 pm

Hum,

I know that I shouldn't ask my question in the same topic, but that's the same solution.

Now, my pb is that simple quote break my code, couldn't I do this :

{def $outputXML = $myObject.data_map.myBlocXML.content.output.output_text|explode("\n"blunk.gif Emoticon|implode(" "blunk.gif Emoticon|explode(" ' "blunk.gif Emoticon|implode(" \' "blunk.gif Emoticon} (without spaces of course)

or

{def $outputXML = $myObject.data_map.myBlocXML.content.output.output_text|explode("\n"blunk.gif Emoticon|implode(" "blunk.gif Emoticon}

{$outputXML|explode(" ' "blunk.gif Emoticon|implode(" \' "blunk.gif Emoticon} (without spaces of course)

Tuesday 10 May 2011 12:21:00 pm

Okey, I guess it's not possible to do two explode implode during the same time.

And for my second purpose, it was missing the set $outputXML = $outputXML|explo...)

But finaly, I don't used this method.

I used the addslashes from php (by adding PHPOperatorList[addslashes=addslashes] in template.ini) and making :

myObject.data_map.myBlocXML.content.output.output_text|explode("\n"blunk.gif Emoticon|implode(" "blunk.gif Emoticon|addslashes()}

Thanks for your help.

Monday 11 September 2017 8:32:50 am

The reply has been removed because of violation of forum rules.

Thursday 16 November 2017 8:12:32 am

The reply has been removed because of violation of forum rules.

expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from