Project

General

Profile

Actions

Feature #90243

closed

Add prefix/suffix message to EmailToSender | EmailToReceiver

Added by Reindl Bernd almost 5 years ago. Updated 5 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Form Framework
Target version:
-
Start date:
2020-01-29
Due date:
% Done:

0%

Estimated time:
PHP Version:
Tags:
Complexity:
Sprint Focus:

Description

It would be nice to have a message field in the EmailToSender and EmailToReceiver finishers.

The form values are enought for the EmailToReceiver mail. But in the mail to the sender its required to write some informations before and after the form values.

Of corse i can set an individual value ({@format}-form1.html -> Finishers/Email/Html-form1.html and Finishers/Email/Plaintext-form1.html) for the template option in this finishers. But so i must create an individual temlate for each form.

It would be also nice to have, if the values can be used in this message fields

Eg.
Hello {lastname},
we have received your request and get in contact with you as soon as possible.

###FIELDDATA###

Best regards
COMPANY

Wish

finishers:
  10:
    options:
      subject: 'Contactform'
      recipientAddress: '{recipient-address}'
      recipientName: ''
      senderAddress: '{sender-address}'
      senderName: '{sender-name}'
      replyToAddress: '{email}'
      carbonCopyAddress: ''
      blindCarbonCopyAddress: ''
      format: html
      attachUploads: false
      messageBefore: "Hello {lastname},\nwe have received..." 
      messageAfter: "Best regards\nCompany" 
    identifier: EmailToReceiver
{namespace formvh=TYPO3\CMS\Form\ViewHelpers}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="format-detection" content="telephone=no">
</head>
<body>
    <f:if condition="messageBefore">
        <p>{messageBefore -> f:format.nl2br()}</p>
    </f:if>
    <table width="600" cellpadding="0" cellspacing="0" border="0">
        <formvh:renderAllFormValues renderable="{form.formDefinition}" as="formValue">
            <tr>
                <td width="600" valign="top" align="left">{formvh:translateElementProperty(element: formValue.element, property: 'label')}</td>
                <td width="600" valign="top" align="left">
                    <f:if condition="{formValue.value}">
                        <f:then>
                            <f:if condition="{formValue.isMultiValue}">
                                <f:then>
                                    <table cellspacing="0" border="0">
                                        <f:for each="{formValue.processedValue}" as="value">
                                            <tr>
                                                <td>{value}</td>
                                            </tr>
                                        </f:for>
                                    </table>
                                </f:then>
                                <f:else>
                                    <table cellspacing="0" border="0">
                                        <tr>
                                            <td><f:format.nl2br>{formValue.processedValue}</f:format.nl2br></td>
                                        </tr>
                                    </table>
                                </f:else>
                            </f:if>
                        </f:then>
                        <f:else>
                            -
                        </f:else>
                    </f:if>
                </td>
            </tr>
        </formvh:renderAllFormValues>
    </table>
    <f:if condition="messageAfter">
        <p>{messageAfter -> f:format.nl2br()}</p>
    </f:if>
</body>
</html>

EmailFinisher.php


    /**
     * @param FormRuntime $formRuntime
     * @return StandaloneView
     * @throws FinisherException
     */
    protected function initializeStandaloneView(FormRuntime $formRuntime): StandaloneView
    {
        $format = ucfirst($this->parseOption('format'));
        $standaloneView = $this->objectManager->get(StandaloneView::class);

        if (isset($this->options['templatePathAndFilename'])) {
            $this->options['templatePathAndFilename'] = strtr($this->options['templatePathAndFilename'], [
                '{@format}' => $format
            ]);
            $standaloneView->setTemplatePathAndFilename($this->options['templatePathAndFilename']);
        } else {
            if (!isset($this->options['templateName'])) {
                throw new FinisherException('The option "templateName" must be set for the EmailFinisher.', 1327058829);
            }
            $this->options['templateName'] = strtr($this->options['templateName'], [
                '{@format}' => $format
            ]);
            $standaloneView->setTemplate($this->options['templateName']);
        }

        $standaloneView->assign('finisherVariableProvider', $this->finisherContext->getFinisherVariableProvider());

        if (isset($this->options['templateRootPaths']) && is_array($this->options['templateRootPaths'])) {
            $standaloneView->setTemplateRootPaths($this->options['templateRootPaths']);
        }

        if (isset($this->options['partialRootPaths']) && is_array($this->options['partialRootPaths'])) {
            $standaloneView->setPartialRootPaths($this->options['partialRootPaths']);
        }

        if (isset($this->options['layoutRootPaths']) && is_array($this->options['layoutRootPaths'])) {
            $standaloneView->setLayoutRootPaths($this->options['layoutRootPaths']);
        }

        if (isset($this->options['variables'])) {
            $standaloneView->assignMultiple($this->options['variables']);
        }

        $standaloneView->assign('form', $formRuntime);
        $standaloneView->assign('messageBefore', $this->parseOption('messageBefore'));
        $standaloneView->assign('messageAfter', $this->parseOption('messageAfter'));
        $standaloneView->getRenderingContext()
            ->getViewHelperVariableContainer()
            ->addOrUpdate(RenderRenderableViewHelper::class, 'formRuntime', $formRuntime);

        return $standaloneView;
    }


Related issues 2 (2 open0 closed)

Related to TYPO3 Core - Feature #84849: Allow links and some HTML tags in label, description, static text, validators, and emailBodyUnder ReviewGabe Troyan2018-04-24

Actions
Related to TYPO3 Core - Feature #88470: Missing custom mail message field. New2019-05-31

Actions
Actions #1

Updated by Reindl Bernd almost 5 years ago

Plaintext template:

<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" xmlns:formvh="http://typo3.org/ns/TYPO3/CMS/Form/ViewHelpers" data-namespace-typo3-fluid="true">
<f:if condition="messageBefore">{messageBefore -> f:format.raw()}

</f:if><formvh:renderAllFormValues renderable="{form.formDefinition}" as="formValue"><f:spaceless>
    <f:if condition="{formValue.isMultiValue}">
        <f:then>
<formvh:translateElementProperty element="{formValue.element}" property="label" />:
    <f:for each="{formValue.processedValue}" as="singleValue">- {singleValue}
    </f:for>
        </f:then>
        <f:else>
<formvh:translateElementProperty element="{formValue.element}" property="label" />: <f:if condition="{formValue.processedValue}"><f:then>{formValue.processedValue -> f:format.raw()}</f:then><f:else>-</f:else></f:if>
</f:else>
    </f:if>
</f:spaceless>
</formvh:renderAllFormValues><f:if condition="messageAfter">

{messageAfter -> f:format.raw()}</f:if>
</html>

Actions #2

Updated by Jarvis H over 4 years ago

Hallo.

I needed the exact same functionality and used variables as a solution. Check the documentation here:[https://docs.typo3.org/c/typo3/cms-form/9.5/en-us/Config/proto/finishersDefinition/finishers/EmailToSender.html#options-variables

In my opinion variables really cover any use case concerning arbitrary mail content so any additional properties should not be needed.

Actions #3

Updated by Paul Hansen over 4 years ago

  • Related to Feature #84849: Allow links and some HTML tags in label, description, static text, validators, and emailBody added
Actions #4

Updated by Mathias Brodala about 4 years ago

  • Subject changed from EmailToSender | EmailToReceiver to Add prefix/suffix message to EmailToSender | EmailToReceiver
Actions #5

Updated by Mathias Brodala about 4 years ago

Actions #6

Updated by Oliver Bartsch 10 months ago

  • Status changed from New to Needs Feedback

Hi Bernd, is this issue resolved for you, using the method described by Jarvis?

Best, Oli

Actions #7

Updated by Riccardo De Contardi 5 months ago

  • Status changed from Needs Feedback to Closed

No feedback since more than 90 days => closing this issue.

If you think that this is the wrong decision or there is still work to do here, please reopen it or open a new issue with a reference to this one.

Thank you and best regards

Actions

Also available in: Atom PDF