简体   繁体   中英

TYPO3 / Fluid: Inline Viewhelper notation in Templates of FluidEmail

I'm using the new TYPO3\CMS\Core\Mail\FluidEmail feature of TYPO3 v10.3 to send HTML system e-mails. Unfortunately, I'm experiencing a weird behavior with Viewhelpers in the e-mail Templates. Calling the regular Viewhelper notation like eg <f:uri.resource extensionName="backend" path="Images/typo3_orange.svg"/> works as expected. But inline notations of the same Viewhelper (like {f:uri.resource(extensionName: 'backend', path: 'Images/typo3_orange.svg')} ) don't get processed at all.

Surprisingly, when I call the regular notation first and the inline notation afterwards in the same template, both notations get resolved.

I also experienced that no fluid variables are accessible in the template, eg {normalizedParams} , which should be available when you set the request like $message->setRequest($GLOBALS['TYPO3_REQUEST']);

Did anyone experience a similar behavior and has a hint for me?

Here's my implementation in my Controller Action:

$message = GeneralUtility::makeInstance(FluidEmail::class);
$message
    ->to($email)
    ->format(FluidEmail::FORMAT_HTML)
    ->setTemplate('MyTemplate')
    ->assign('pages', $pages);
if ($GLOBALS['TYPO3_REQUEST'] instanceof ServerRequestInterface) {
    $message->setRequest($GLOBALS['TYPO3_REQUEST']);
}
GeneralUtility::makeInstance(Mailer::class)->send($message);

Reference: https://docs.typo3.org/c/typo3/cms-core/master/en-us/Changelog/10.3/Feature-90266-Fluid-basedTemplatedEmails.html

Sounds like a fluid parsing problem. Do you have any { or } flying around in your template that could mess up fluids parsing?

Just run into the same problem with one of my in-house plugins after switching from php7.2 to php7.4 (when switching back to php7.2 the resource path was resolved again correctly).

It turned out that some inline javascript using curly brackets further down the page was to blame (thank you Daniel). Putting it in a separate file solved the issue. It would appear that the use of inline JS is tolerated to different degrees depending on the php version being used.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM