[TYPO3-mvc] Mailing from the scheduler

Markus Klein klein.t3 at mfc-linz.at
Thu Feb 7 00:01:43 CET 2013


Hi!

I always initialize my standalone views like this, in order to be able to use the f:translate viewhelper without specifying the whole path to the LL-file:

$template = t3lib_div::makeInstance('Tx_Fluid_View_StandaloneView', $this->cObj);
/* @var $template Tx_Fluid_View_StandaloneView */
$template->getRequest()->setControllerExtensionName($this->extKey);

Kind regards
Markus

> 
> When you use the Fluid Standalone Template you have to fully reference your labels, that is, using the full path.
> I saw in the latest versions you can also add extensionName attribute to the viewhelper thus overriding the default extensionName.
> Not sure if this works in standalone view as well though.
> 
> Kind regards,
> 
> Henjo
> 
> Problems are small because we learned how to deal with them.
> Problems are big because we need to learn how to deal with them.
> 
> 
> On Wed, Feb 6, 2013 at 3:41 PM, Tobias Liebig <tobias.liebig at typo3.org>wrote:
> 
> > Hej,
> >
> > compared with a MailService i did some time ago, i have this
> > additional line of code, right before rendering the view:
> >
> > $emailView->getRequest()->setControllerExtensionName($this->extensionN
> > ame);
> >
> > Maybe that helps.
> >
> > kind regards
> >    Tobias
> >
> >
> > Am 05.02.2013 um 22:02 schrieb Lars Nieuwenhuizen <
> > lars.nieuwenhuizen at me.com>:
> >
> > > Good day,
> > >
> > > I have a question regarding the following:
> > >
> > > I have a scheduler class which extends Tx_Extbase_Scheduler_Task In
> > > this class i've created an email function:
> > >
> > > ################################
> > >
> > >       /**
> > >        * Send email
> > >        *
> > >        * @param User $recipient
> > >        * @param array $sender
> > >        * @param string $subject
> > >        * @param string $templateName
> > >        * @param $templateType
> > >        * @param array $variables
> > >        * @return boolean
> > >        */
> > >       protected function sendTemplateEmail($recipient, array
> > > $sender,
> > $subject, $templateName, $templateType, array $variables = array()) {
> > >               $emailView =
> > $this->objectManager->create('Tx_Fluid_View_StandaloneView');
> > >
> > >               $emailView->setFormat($templateType);
> > >
> > >               $templateRootPath =
> > t3lib_div::getFileAbsFileName('EXT:extension/Resources/Private/Templat
> > es/');
> > >               $templateLayoutRootPath =
> > t3lib_div::getFileAbsFileName('EXT:extension/Resources/Private/Layouts
> > /');
> > >               $templatePartialRootPath =
> > t3lib_div::getFileAbsFileName('EXT:extension/Resources/Private/Partial
> > s/');
> > >
> > >               $templatePathAndFilename = $templateRootPath . 'Email/' .
> > $templateName . '.html';
> > >               $emailView->setLayoutRootPath($templateLayoutRootPath);
> > >
> > > $emailView->setPartialRootPath($templatePartialRootPath);
> > >
> > $emailView->setTemplatePathAndFilename($templatePathAndFilename);
> > >
> > >               $emailView->assignMultiple($variables);
> > >               $emailView->assign('webUser', $recipient);
> > >
> > >               $emailBody = $emailView->render();
> > >
> > >               $message =
> > > t3lib_div::makeInstance('t3lib_mail_Message');
> > >
> > >               $message->setTo($recipient->getEmail())
> > >                       ->setFrom($sender)
> > >                       ->setSubject($subject);
> > >               // Plain text example
> > >               $message->setBody($emailBody, 'text/' .
> > > $templateType);
> > >
> > >               $message->send();
> > >               return $message->isSent();
> > >       }
> > >
> > > ################################
> > >
> > > When the mail is sent, i receive the email without any of the
> > > language
> > labels. My urls that fluid should format are messed up.
> > > The entire email is wasted… Probably because it is all outside of
> > > the
> > scope. Is there any way to make this work?
> > >
> > > Thanks in advance,
> > >




More information about the TYPO3-project-typo3v4mvc mailing list