Forums / Setup & design / remove return carriage from XML output

remove return carriage from XML output

Author Message

Jean-Baptiste Crestot

Monday 09 May 2011 2:07:10 am

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...");
   

So it break my javascript code!

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

Thank's for answer,

JB Crestot

Marko Žmak

Monday 09 May 2011 3:07:04 am

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.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Jean-Baptiste Crestot

Monday 09 May 2011 3:29:52 am

Oh god...

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

Quoc Huy Nguyen Dinh

Monday 09 May 2011 4:16:39 am

Alternatively you could do

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

Not tested though...

Jean-Baptiste Crestot

Monday 09 May 2011 4:41:26 am

"

Alternatively you could do

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

Not tested though...

"

Thank's for answer, but it doesn't work. :(

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

Thank you a lot.

Jean-Baptiste Crestot

Monday 09 May 2011 8:08:48 am

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")|implode(" ")|explode(" ' ")|implode(" \' ")} (without spaces of course)

or

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

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

Jean-Baptiste Crestot

Tuesday 10 May 2011 3:21:00 am

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")|implode(" ")|addslashes()}

Thanks for your help.

eZ debug

Timing: Jan 17 2025 20:57:30
Script start
Timing: Jan 17 2025 20:57:30
Module start 'content'
Warning: PHP: E_DEPRECATED Jan 17 2025 20:57:30
trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/ze/public_html/share.se7enx.com/var/community/cache/template/compiled/table-c0a31fef795ad927ef08940ddf2d392f.php on line 147
Timing: Jan 17 2025 20:57:31
Module end 'content'
Timing: Jan 17 2025 20:57:31
Script end

Main resources:

Total runtime1.0491 sec
Peak memory usage4,096.0000 KB
Database Queries209

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0157 596.1641180.8359
Module start 'content' 0.01570.9399 777.0000685.6641
Module end 'content' 0.95570.0933 1,462.6641341.5156
Script end 1.0490  1,804.1797 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00380.3624210.0002
Check MTime0.00140.1379210.0001
Mysql Total
Database connection0.00210.196810.0021
Mysqli_queries0.956491.16872090.0046
Looping result0.00160.15642070.0000
Template Total1.017597.020.5088
Template load0.00210.199420.0010
Template processing1.015496.789320.5077
Template load and register function0.00010.013010.0001
states
state_id_array0.00040.039810.0004
state_identifier_array0.00060.060520.0003
Override
Cache load0.00190.1800610.0000
Sytem overhead
Fetch class attribute can translate value0.00120.118440.0003
Fetch class attribute name0.00090.081890.0001
XML
Image XML parsing0.00140.133940.0004
class_abstraction
Instantiating content class attribute0.00000.001290.0000
General
dbfile0.00250.2368370.0001
String conversion0.00000.000830.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
7content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/td.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/td.tplEdit templateOverride template
4content/datatype/view/ezxmltags/tr.tpl<No override>extension/community/design/community/templates/content/datatype/view/ezxmltags/tr.tplEdit templateOverride template
1content/datatype/view/ezxmltags/table.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/table.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltags/link.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/link.tplEdit templateOverride template
1content/datatype/view/ezxmltags/quote.tpldatatype/ezxmltext/quote.tplextension/ezwebin/design/ezwebin/override/templates/datatype/ezxmltext/quote.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 31
 Number of unique templates used: 10

Time used to render debug report: 0.0002 secs