Pass variable to all email templates
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
-
- Expert
- Posts: 274
- Joined: 27 Jun 2019, 16:19
Pass variable to all email templates
Hi Aimeos!
Is it possible to pass variable to all email templates? I tried to add decorator but it doesn't work..
Here is decorator:
Partial:
but settings variable not accessable in email templates (
Is it possible to pass variable to all email templates? I tried to add decorator but it doesn't work..
Here is decorator:
Code: Select all
namespace Aimeos\Controller\Jobs\Common\Decorator;
class CustomDecorator extends Base
{
protected $partialHelper;
public function __construct(\Aimeos\Controller\Jobs\Iface $controller, \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\Bootstrap $aimeos)
{
parent::__construct($controller, $context, $aimeos);
$view = $context->getView();
$view->settings = 324234;
$view->addHelper('partial', $this->getPartialHelper($view));
}
protected function getPartialHelper(\Aimeos\MW\View\Iface $view)
{
if(!$this->partialHelper) {
$this->partialHelper = new \Aimeos\Controller\Jobs\Common\Helper\Partial\Partial($view);
}
return $this->partialHelper;
}
}
Code: Select all
class Partial extends \Aimeos\MW\View\Helper\Partial\Standard
{
public function transform(string $file, array $params = []): string
{
$view = $this->getView();
$params['settings'] = 234234342;
dd(76567);
return parent::transform($file, $params);
}
}
but settings variable not accessable in email templates (
Re: Pass variable to all email templates
This doesn't work because the emails are not generated using partials which are only a way to include the output from another template.
You can create a HTML client decorator and implement the addData() method which then adds your settings to the passed view like described here: https://aimeos.org/docs/latest/frontend ... omponents/
The configuration to apply the decorator to ALL HTML clients (not only for the email ones) would be:
You can create a HTML client decorator and implement the addData() method which then adds your settings to the passed view like described here: https://aimeos.org/docs/latest/frontend ... omponents/
The configuration to apply the decorator to ALL HTML clients (not only for the email ones) would be:
Code: Select all
client/html/common/decorators/default = ['Mydecorator']
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star