Respant
Respant

Reputation: 198

Parse TYPO3 links in CommandController

I have saved TYPO3 text (bodytext) in database. It contains different links saved in t3 format:

<p><a href="t3://page?uid=700" target="_blank" class="internal" title="title">Link</a> more text.</p>

The idea is create some script as CommandController, get this saved text and send it via email by cron. The problem is links will not be converted in proper html without frontend environment (it works fine, if I do the same inside frontend plugin).

I tried to render this text with fluid html view helper:

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

Also tried to parse text with $contentObject->parseFunc directly inside my CommandController. But it will just cut off link.

Is any simple TYPO3 function to convert bodytext in real html?

Note: typo3 version 8.7.16

Upvotes: 1

Views: 1337

Answers (1)

Geee
Geee

Reputation: 2249

Okay, It seems links are not being parsed and I don't think it's an issue with CommandController. I had same issue and found several ways to fix this issue.

Issue with EXT: frontend_editing

After uninstalling every non-vital extension and clearing every possible cache and a few hours of debugging we have found the problem: the "frontend_editing" extension - only if the user is logged in into the backend!

Issue at GitHub

  • Same issue discussed on Github, you can check it out here

@csba described detailed answer here!

Issue with EXR:fluid_styled_content

Another issue is with format viewhelper, @georg-ringer has explained solution for fixing issue and it works for me. Check it out here for more detail.

As per @georg-ringer answer, you can just change <f:format.html>{item.bodytext}</f:format.html> to <f:format.raw>{item.bodytext}</f:format.raw>. Probably this will fix your problem.

Extbase parse with link service.

// use TYPO3\CMS\Core\LinkHandling\LinkService;
$linkService = GeneralUtility::makeInstance(LinkService::class);
$linkDetails = $linkService->resolve($firstparameter);

You can parse link as shown above, you can find the reference below:

Upvotes: 0

Related Questions