Note |
---|
This FieldType is not officially supported yet, it will be as of first stable eZ Platform release. |
This FieldType This Field Type validates and stores structured richtextrich text, and exposes it in several formats.
...
Table of Contents | ||
---|---|---|
|
Input expectations
Type | Description | Example |
---|---|---|
string | XML document in one of the FieldTypeField Type's input formats as a string. | See the example below. |
DOMDocument | XML document in one of the FieldTypeField Type's input formats as a
| See the example below. |
eZ\Publish\Core\FieldType\RichText\Value | An instance of the FieldTypeField Type's Value object. | See the example below. |
Input formats
FieldType Field Type works with XML and also expects an XML value as input, wether whether as a string, DOMDocument
object or FieldTypeField Type's Value
object. When the value is given as a string or a DOMDocument
object, it will be checked for conformance to the with one of the supported input formats, then dispatched to the appropriate converter, to be converted to the FieldTypeField Type's internal format. No conversion will be performed if providing the value in FieldTypeField Type's internal format , or when providing the value as FieldTypeas Field Type's Value
object. In the latter case it will be expected that Value
object holds the value in FieldTypeField Type'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 |
Example of the FieldTypeField Type's internal format
Code Block | ||||
---|---|---|---|---|
| ||||
<?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> <para ezxhtml:class="paraClass">This is a paragraph.</para> </section> |
Example of the FieldTypeField Type's XHTML5 edit format
Warning |
---|
This format is used by eZ Platform Online Editor and will change with it's needs as we continue to evolve this part of the UI. |
...
Info |
---|
For more information about internal format and input formats, see FieldTypeField Type's conversion test fixtures on GitHub. |
Example of using XML document in internal format as a string
Code Block | ||||
---|---|---|---|---|
| ||||
... $contentService = $repository->getContentService(); $contentTypeService = $repository->getContentTypeService(); $contentType = $contentTypeService->loadContentTypeByIdentifier( "article" ); $contentCreateStruct = $contentService->newContentCreateStruct( $contentType, "eng-GB" ); $inputString = <<<DOCBOOK <?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> <para ezxhtml:class="paraClass">This is a paragraph.</para> </section> DOCBOOK; $contentCreateStruct->setField( "description", $inputString ); ... |
Value object API
eZ\Publish\Core\FieldType\RichText\Value
offers following properties:
Property | Type | Description |
---|---|---|
xml | DOMDocument | Internal format value as an instance of DOMDocument . |
REST API specifics
Creating or updating Content
When creating RichText content with the REST API, it is possible to provide data as a string, using the "xml
" fieldValue key:
...
When the value given over REST API is transformed into a FieldTypeField Type's Value
object, it will be treated as a string. This means you can use any supported input format for input over REST API.