This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit

eZ Community » Forums » Developer » ezpublish 4 legacy api export content...

ezpublish 4 legacy api export content of ezxmltext datatype

ezpublish 4 legacy api export content of ezxmltext datatype

Wednesday 15 October 2014 5:25:33 pm - 1 reply

Hey guys,

I have a question that hopefully someone else knows the answer to.

We have 2 sites in production. One implemented on eZ4 and one implemented in eZ5. Now I have created a command on the new site to import some content from the old site, using the data provided through the API endpoints like  :


Everything seems OK, just that we are not able to retrieve the html content of the attributes XMLBlock because the API returns the content without any HTML or XML tags.

Any suggestions here? 

I was thinking into digging into the API and customizing it but would rather have a second opinion before doing this.

Thanks in advance

Modified on Wednesday 15 October 2014 5:30:18 pm by Maior Valentin

Thursday 16 October 2014 4:03:34 pm

Finally, I decided to create an extension that overrides ezprestapiprovider.

The problem was actually that in ezpRestContentModel there was:

    case 'ezxmltext':               

     $html = $field->content->attribute( 'output' )->attribute( 'output_text' );               

    $attributeValue = array( strip_tags( $html ) );


So I created a new extension that extends all the classes of the initial extension and in settings/rest.ini.append.php I addedd 



All the other classes just extended the original classes like this:


     class MyRestContentModel extends ezpRestContentModel

    -- overriden public function doList()  and changed these lines

       $result->variables['childrenNodes'] = MyRestContentModel ::getChildrenList( $crit, $this->request, $this->getResponseGroups() );

       $childrenCount = MyRestContentModel ::getChildrenCount( $crit );


    class MyRestContentModel extends ezpRestContentModel

      public static function attributeOutputData( ezpContentField $field )   {   

       if ($field->data_type_string == 'ezxmltext') {     

        $html = $field->content->attribute( 'output' )->attribute( 'output_text' );     

        $attributeValue = array($html);    }

       else {     

            $html = ezpRestContentModel::attributeOutputData($field);   

    return $html; 


INSIDE public static function getChildrenList changed ezpRestContentController to MyRestContentController


    class MyRestApiProvider extends ezpRestApiProvider

      function getRoutes()   {   

      $routes = parent::getRoutes();   

      $routes['ezpList'] = new ezpRestVersionedRoute(               

          new ezpMvcRegexpRoute( '@^/content/node/(?P<nodeId>\d+)/list(?:/offset/(?P<offset>\d+))?          (?:/limit/(?P<limit>\d+))?(?:/sort/(?P<sortKey>\w+)(?:/(?P<sortType>asc|desc))?)?$@',                    'MYRestContentController', 'list' ), 1                );    return $routes; 


(myextension/view_controller.php) --- nothing added just overriden

    class MyRestApiViewController extends ezpRestApiViewController


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

36 542 Users on board!

Forums menu

Proudly Developed with from