Header image

Symfony Finland
Random things on PHP, Symfony and web development

Convert RichText to HTML in PHP API

eZ Platform stores Rich Text internally in XML. To convert this XML to HTML markup common in web projects, you can use this API:

$xhtml5Converter = $this->container->get('ezpublish.fieldType.ezrichtext.converter.output.xhtml5');
$xml = $view->getContent()->getFieldValue('content')->xml;
$html = $xhtml5Converter->convert($xml)->saveHTML();
echo $html;

Written by Jani Tarvainen on Monday January 21, 2019
Permalink -

Leave a comment

comments powered by Disqus

« Update or create multiple languages at once using eZ Platform PHP API - Load Location / Content by URL Alias in eZ Platform »