This site has been archived. To learn more about our current products Ibexa Content, Ibexa Experience, Ibexa Commerce head over to the Ibexa Developer Portal

eZ Community » Forums » Developer » Using the powercontent extension to...
expandshrink

Using the powercontent extension to store data in a XML block

Using the powercontent extension to store data in a XML block

Monday 22 August 2011 1:00:59 pm - 2 replies

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?

Modified on Wednesday 24 August 2011 9:38:54 am by Jon Arvid Ludviksen

Wednesday 24 August 2011 9: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.

Modified on Wednesday 24 August 2011 11:37:10 am by Jon Arvid Ludviksen

Thursday 25 August 2011 10: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,

expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from