0

I created a custom extension for TYPO3 CMS. It basically does some database queries to get text from database. As I have seen, TYPO3 editor, transforms data before storing it in database so for example a link <a href="....." >Link</a> is stored as <link href>My Link Text</link> and so on for many tags like this. when I query data from DB, I get it as it is stored in DB (<link href>My Link Text</link>) so links are not displayed as they shoud. They display as normal text..

As far as I know there are two ways to go:

  1. disable RTE transformations (how to do that?)

  2. use lib.parseFunc_RTE (which i have no Idea how to configure it properly)

any idea? thanks.

biesior
  • 55,576
  • 10
  • 125
  • 182
Altin
  • 2,175
  • 3
  • 25
  • 47

4 Answers4

3

I guess you're not using Extbase and Fluid? Just as a reference, if you are using Extbase and Fluid for your extension you can render text from the RTE using Fluid:

<f:format.html>{bodytext}</f:format.html>

This uses lib.parseFunc_RTE to render the RTE text as HTML. You can also tell it to use a different TypoScript object for the rendering:

<f:format.html parseFuncTSPath="lib.my_parseFunc">{bodytext}</f:format.html>

Useful documentation:

Leon de Rijke
  • 158
  • 2
  • 6
  • The attribute is actually called parseFuncTSPath, not parseFunc. The full syntax for the standard RTE transform would be {bodytext} – j4k3 Mar 19 '15 at 08:13
  • 1
    Good catch! I updated my answer. By default it uses the standard RTE transform, so no need to include that again. – Leon de Rijke Mar 20 '15 at 08:40
1

I came across the same problem, but using EXTBASE the function "pi_RTEcssText" ist not available anymore. Well maybe it is, but I didn't know how to include it.

Anyway, here's my solution using EXTBASE:

$this->cObj = $this->configurationManager->getContentObject();
$bodytext = $this->cObj->parseFunc($bodyTextFromDb, $GLOBALS['TSFE']->tmpl->setup['lib.']['parseFunc_RTE.']);

This way I get the RTE formatted text.

Klaus
  • 416
  • 4
  • 15
  • thanks for the good attitude of sharing for others. I don't use Typo3 anymore because I quit my job 10 months ago (I was never really quite into Typo3, my friend was), but sharing your solution might save others many hours or days of frustration :) – Altin Dec 21 '13 at 02:25
1

I have managed to do it by configuring the included typoscript:

# Creates persistent ParseFunc setup for non-HTML content. This is recommended to use (as a reference!)
lib.parseFunc {
makelinks = 1
makelinks.http.keep = {$styles.content.links.keep}
makelinks.http.extTarget < lib.parseTarget
makelinks.http.extTarget =
makelinks.http.extTarget.override = {$styles.content.links.extTarget}
makelinks.mailto.keep = path
tags {
    link = TEXT
    link {
        current = 1
        typolink.parameter.data = parameters : allParams
        typolink.extTarget < lib.parseTarget
        typolink.extTarget =
        typolink.extTarget.override = {$styles.content.links.extTarget}
        typolink.target < lib.parseTarget
        typolink.target =
        typolink.target.override = {$styles.content.links.target}
        parseFunc.constants =1
    }
}
allowTags = {$styles.content.links.allowTags}

And denied tag link:

denyTags = link

sword = <span class="csc-sword">|</span>
constants = 1

nonTypoTagStdWrap.HTMLparser = 1
nonTypoTagStdWrap.HTMLparser {
    keepNonMatchedTags = 1
    htmlSpecialChars = 2
}
}
David Rosa
  • 69
  • 2
  • thanks for your answer @David. This question is from 2 years ago and I no longer work with Typo3 since I quit my day job - I almost forgot everything about it. But I hope it helps someone else that may come across ;) – Altin Dec 04 '14 at 16:43
0

Well, just so if anyone else runs into this problem,

I found one way to resolve it by using pi_RTEcssText() function inside my extension file:

$outputText=$this->pi_RTEcssText( $value['bodytext'] );

where $value['bodytext'] is the string I get from the database-query in my extension.

This function seems to process data and return the full HTML (links, paragraphs and other tags inculded).

Note: If you haven't already, it requires to include this file:

require_once(PATH_tslib.'class.tslib_pibase.php');

on the top of your extension file.

That's it basically.

Nissa
  • 4,636
  • 8
  • 29
  • 37
Altin
  • 2,175
  • 3
  • 25
  • 47