This format is used by eZ P
This FieldType is not officially supported yet, it will be as of first stable eZ Platform release. |
This FieldType validates and stores structured richtext, and exposes it in several formats.
Name | Internal name | Expected input |
---|---|---|
RichText | ezrichtext | mixed |
Type | Description | Example |
---|---|---|
string | XML document in one of the FieldType's input formats as a string. | See the example below. |
DOMDocument | XML document in one of the FieldType's input formats as a | See the example below. |
eZ\Publish\Core\FieldType\RichText\Value | An instance of the FieldType's Value object. | See the example below. |
FieldType works with XML and also expects an XML value as input, wether as a string, DOMDocument
object or FieldType's Value
object. When the value is given as a string or a DOMDocument
object, it will be checked for conformance to the one of the supported input formats, then dispatched to the appropriate converter, to be converted to the FieldType's internal format. No conversion will be performed if providing the value in FieldType's internal format, or when providing the value as FieldType's Value
object. In the latter case it will be expected that Value
object holds the value in FieldType's internal format.
Currently supported input formats are described in the table below:
Name | Description |
---|---|
eZ Publish Docbook variant | FieldType's internal format |
XHTML5 editing format | Typically used with in-browser HTML editor |
Legacy eZXML format | Compatibility with legacy eZXML format, used by XmlText FieldType |
<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ezxhtml="http://ez.no/xmlns/ezpublish/docbook/xhtml" xmlns:ezcustom="http://ez.no/xmlns/ezpublish/docbook/custom" version="5.0-variant ezpublish-1.0"> <title ezxhtml:level="2">This is a title.</title> <para ezxhtml:class="paraClass">This is a paragraph.</para> </section> |
This format is used by eZ Platform Online Editor and will change with its needs as we continue to evolve this part of the UI. |
<section xmlns="http://ez.no/namespaces/ezpublish5/xhtml5/edit"> <h2>This is a title.</h2> <p class="paraClass">This is a paragraph.</p> </section> |
For more information about internal format and input formats, see FieldType's conversion test fixtures on GitHub. |
For example, ezxml does not use explicit level attributes for <header> elements, instead <header> element levels are indicated through the level of nesting inside <section> elements. |
... $contentService = $repository->getContentService(); $contentTypeService = $repository->getContentTypeService(); $contentType = $contentTypeService->loadContentTypeByIdentifier( "article" ); $contentCreateStruct = $contentService->newContentCreateStruct( $contentType, "eng-GB" ); $inputString = <<<DOCBOOK <section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ezxhtml="http://ez.no/xmlns/ezpublish/docbook/xhtml" xmlns:ezcustom="http://ez.no/xmlns/ezpublish/docbook/custom" version="5.0-variant ezpublish-1.0"> <title ezxhtml:level="2">This is a title.</title> <para ezxhtml:class="paraClass">This is a paragraph.</para> </section> DOCBOOK; $contentCreateStruct->setField( "description", $inputString ); ... |
eZ\Publish\Core\FieldType\RichText\Value
offers following properties:
Property | Type | Description |
---|---|---|
xml | DOMDocument | Internal format value as an instance of DOMDocument . |
When creating RichText content with the REST API, it is possible to provide data as a string, using the "xml
" fieldValue key:
<fieldValue> <value key="xml"><?xml version="1.0" encoding="UTF-8"?> <section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ezxhtml="http://ez.no/xmlns/ezpublish/docbook/xhtml" xmlns:ezcustom="http://ez.no/xmlns/ezpublish/docbook/custom" version="5.0-variant ezpublish-1.0"> <title ezxhtml:level="2">This is a title.</title> </section> </value> </fieldValue> |
When the value given over REST API is transformed into a FieldType's Value
object, it will be treated as a string. This means you can use any supported input format for input over REST API.