Forums / Developer / Using the powercontent extension to store data in a XML block

Using the powercontent extension to store data in a XML block

Author Message

Jon Arvid Ludviksen

Monday 22 August 2011 4:00:59 am

To improve my site I'm using the powercontent extension for some simple publishing.
It's working great for both Text block and Text line. But now I'm trying to use it with a XML block and am having trouple getting content on multiple lines.
Input gets stored in one paragraph:

 ...
 <paragraph xmlns:tmp="http://ez.no/namespaces/ezpublish3/temporary/">123</paragraph>
 ...

When in fact it should be stored like this:

 ...
 <paragraph>
 <line xmlns:tmp="http://ez.no/namespaces/ezpublish3/temporary/">1</line>
 <line xmlns:tmp="http://ez.no/namespaces/ezpublish3/temporary/">2</line>
 <line xmlns:tmp="http://ez.no/namespaces/ezpublish3/temporary/">3</line>
 </paragraph>
 ...

I don't need the ezoe-toolbar as I'm just using this for simple quick publishing. Therefore my textarea just looks like the one I use for Text block:

 <textarea name="powercontent_message_xml_ContentObjectAttribute_data_text_pcattributeid"> </textarea>

Any tips on how I could achieve this and how I should go about it?

Jon Arvid Ludviksen

Wednesday 24 August 2011 12:37:32 am

Really?!

Nobody has any suggestions on which direction I should take to solve this. I've hit a dead end...

Update:

I found a solution and for future reference her it is. I haven't tested it extensively or gone live with it yet. But it looks like it will do the trick, other suggestions are still welcome!

in powercontent/modules/powercontent/action.php i added this function

 function htmlToXML($html) {
    $xml = $html;
    $xml = str_replace( "\r", "<br/>", $xml );
    
    $parser = new eZSimplifiedXMLInputParser(0,  false, false);
    $document = $parser->process($xml);
  if ( !is_object( $document ) ) {
      return null;
  }
    
    $domString = eZXMLTextType::domString($document);
    return $domString;
}

And then replaced

 $http->setPostVariable( $newPostVariable, $postValue );

with

 $dataTypeString = $dataMap[$possibleAttributeIdentifier]->attribute( 'data_type_string' );


 if ( $dataTypeString == "ezxmltext" )
 {
         eZDebug::writeNotice( 'Found XML block attribute: ' . $possibleAttributeIdentifier );    
         $postValue = htmlToXML(trim($postValue));
 }
$http->setPostVariable( $newPostVariable, $postValue );

PS: I'm still not getting namespaces on the line-tags but will look into that as well.

Nicolas Pastorino

Thursday 25 August 2011 1:02:45 am

Hi Jon Arvid, 

While i do not know powercontent in-depth, it seems like your workaround/solution corresponds to a common need. How about pushing it into the extension directly ? 
You could request membership to the team there : http://projects.ez.no/powercontent/team/members (you need to be logged-in).

Cheers,

--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye

eZ debug

Timing: Jan 17 2025 20:55:50
Script start
Timing: Jan 17 2025 20:55:50
Module start 'content'
Timing: Jan 17 2025 20:55:50
Module end 'content'
Timing: Jan 17 2025 20:55:50
Script end

Main resources:

Total runtime0.1483 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0053 596.3047180.8047
Module start 'content' 0.00530.0044 777.1094100.3594
Module end 'content' 0.00970.1385 877.4688527.6406
Script end 0.1483  1,405.1094 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00332.2295200.0002
Check MTime0.00130.8709200.0001
Mysql Total
Database connection0.00080.533910.0008
Mysqli_queries0.106471.72751410.0008
Looping result0.00110.75521390.0000
Template Total0.138393.210.1383
Template load0.00070.494010.0007
Template processing0.137592.719810.1375
Override
Cache load0.00050.355310.0005
Sytem overhead
Fetch class attribute can translate value0.00060.379610.0006
XML
Image XML parsing0.00020.157010.0002
General
dbfile0.00332.2431200.0002
String conversion0.00000.003530.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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs