Skip to content

Commit

Permalink
Update "RTE Transformations" (#924)
Browse files Browse the repository at this point in the history
  • Loading branch information
IndyIndyIndy authored and lolli42 committed Sep 1, 2020
1 parent b9d0087 commit f3626fa
Showing 1 changed file with 16 additions and 24 deletions.
40 changes: 16 additions & 24 deletions Documentation/ApiOverview/Rte/Transformations/Introduction.rst
Expand Up @@ -62,26 +62,27 @@ This is how the content in the database could look for a hybrid mode
.. code-block:: html
:linenos:

This is line number 1 with a <link 123>link</link> inside
This is line number 1 with a <a href="t3://page?uid=123">link</a> inside
This is line number 2 with a <b>bold part</b> in the text
<p align="center">This line is centered.</p>
This line is just plain


As you can see the TYPO3-specific tag,
:code:`<link>` is used for the link to page 123. This tag is designed to be
easy for editors to insert. It is of course converted to a real :code:`<a>`
tag when the page is rendered in the frontend. Further line 2 shows
:code:`<a href="t3://page?uid=123">` is used for the link to page 123.
This tag is designed to be easy for editors to insert and easy for TYPO3
to parse and understand. The t3:// scheme is later resolved to a real
link in the frontend by the :ref:`linkhandler`. Further line 2 shows
bold text. In line 3 the situation is that the paragraph should be
centered - and there seems to be no other way than wrapping the line
in a :code:`<p>` tag with the "align" attribute. Not so human readable but we
can do no better without an RTE. Line 4 is just plain.

Generally this content will be processed before output on a page of
course. Typically the rule will be this: "Wrap each line in a :code:`<p>` tag
which is not already wrapped in a :code:`<p>` tag and convert all
TYPO3-specific :code:`<link>`-tags to real :code:`<a>` tags." and thus the final
result will be valid HTML.
which is not already wrapped in a :code:`<p>` tag and run all
:code:`<a>`-tags with TYPO3-specific schemes through a Linkhandler to
resolve them to real uris." and thus the final result will be valid HTML.


.. _transformations-hybrid-modes-rte:
Expand All @@ -92,13 +93,12 @@ In RTE
The content in the database can easily be edited as plain text thanks
to the "hybrid-mode" used to store the content. But when the content
above from the database has to go into the RTE it *will not* work if
every line is not wrapped in a :code:`<p>` tag! The same is true for the
:code:`<link>` tag, which has to be converted for the RTE to understand it.
every line is not wrapped in a :code:`<p>` tag!
This is what eventually goes into the RTE:

.. code-block:: xml
<p>This is line number 1 with a <a href="index.php?id=123">link</a> inside</p>
<p>This is line number 1 with a <a href="t3://page?uid=123">link</a> inside</p>
<p>This is line number 2 with a <strong>bold part</strong> in the text</p>
<p align="center">This line is centered.</p>
<p>This line is just plain</p>
Expand Down Expand Up @@ -128,23 +128,15 @@ Where Transformations are Performed

The transformations you can do with TYPO3 are done in the class
:code:`\TYPO3\CMS\Core\Html\RteHtmlParser`. There is typically a function for each
direction; From DB to RTE (suffixed :code:`_rte`) and from RTE to DB
(suffixed :code:`_db`).
direction; From DB to RTE and from RTE to DB.

The transformations are invoked in two cases:

- **Before content enters the editing form** This is done by the RTE API
itself, calling the method :code:`\TYPO3\CMS\Backend\Rte\AbstractRte::transformContent()`.

- **Before content is saved in the database** This is done in
:code:`\TYPO3\CMS\Core\DataHandling\DataHandler` class and the transformation is triggered by a pseudo-
field from the submitted form! This field is added by the RTE API
(calling :code:`\TYPO3\CMS\Backend\Rte\AbstractRte::triggerField()`). Lets say the fieldname is
:code:`data[tt_content][456][bodytext]` then the trigger field is named
:code:`data[tt_content][456][_TRANSFORM_bodytext]` and in :code:`\TYPO3\CMS\Core\DataHandling\DataHandler`
this pseudo-field will be detected and used to trigger the
transformation process from RTE to DB. Of course the pseudo field will
never go into the database (since it is not found in :code:`$TCA`).
- **Before content enters the editing form** This is done by calling the method
:code:`\TYPO3\CMS\Core\Html\RteHtmlParser::transformTextForRichTextEditor()`.

- **Before content is saved in the database** This is done by calling the method
:code:`\TYPO3\CMS\Core\Html\RteHtmlParser::transformTextForPersistence()`.

The rationale for transformations is discussed in :ref:`appendix-a`.

0 comments on commit f3626fa

Please sign in to comment.