[Flow] StandaloneView for emails and templatePathAndFileName

Steffen Wickham steffen at gaming-inc.de
Fri Aug 9 10:00:05 CEST 2013


Hello Mark,

you can use the "resource://" notation for refering the template file.
This is my approach I use very often, so I put it in an own method
within my package "AFSVN.Basic":


/**
     * <SOME DESCRIPTION>
     *
     * @param string $templateFile
     * @return \TYPO3\Fluid\View\StandaloneView
     */
    protected function initializeStandaloneFluid( $templateFile ) {
        /** @var \TYPO3\Fluid\View\StandaloneView $fluid */
        $fluid =
$this->objectManager->get('\TYPO3\Fluid\View\StandaloneView');
//       
$fluid->setLayoutRootPath('resource://AFSVN.Basic/Private/Layouts');
//       
$fluid->setPartialRootPath('resource://AFSVN.Basic/Private/Partials');
        $fluid->setFormat('html');
        $fluid->setTemplatePathAndFilename( $templateFile );
        $fluid->setControllerContext( $this->getControllerContext() );
        $fluid->assign('langDetector', $this->lang->getLanguage());
        $fluid->assign('currentSeason', $this->currentSeason);

        return $fluid;
    }

So I just call the method and get a brand new instance with all
important values set. An example call could be:
$vcardTemplate =
$this->initializeStandaloneFluid('resource://AFSVN.Basic/Private/Templates/Referee/VCard.txt');

Best regards,
Steffen




Am 09.08.13 06:27, schrieb Mark Kuiphuis:
> Hi all,
>
> In TYPO3 Flow I would like to use a template for sending out an email.
> I have been using this functionality before in Extbase, but was
> wondering if the code below is the way to go to actually set the
> templatePathAndFileName or is there a better approach where I don't
> have to hardcode the dir/to/file after the FLOW_PATH_ROOT constant?
>
> It will be called from within an action within a controller...
>
> $emailView = new \TYPO3\Fluid\View\StandaloneView();
> $emailView->setFormat('html');
>
> $templatePathAndFileName = FLOW_PATH_ROOT .
> 'Packages/Application/Vendor.PackageName/Resources/Private/Templates/Front/Password/Email.html';
>         $emailView->setTemplatePathAndFilename($templatePathAndFileName);
>
> ...
> ...
> ...
>
> $emailBody = $emailView->render();
>
> Thanks,
>
> Kind regards,
>
> Mark Kuiphuis
> _______________________________________________
> Flow mailing list
> Flow at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow



More information about the Flow mailing list