Php Symfony:无法将额外变量从我的控制器添加到twig
我对以下代码有问题: 控制器Php Symfony:无法将额外变量从我的控制器添加到twig,php,symfony,variables,twig,Php,Symfony,Variables,Twig,我对以下代码有问题: 控制器 $langage = $request->request->get('langage-choisis'); $baturl = "href=\"http://localhost:8000/?keyview=".$keypreview."&order=".$numerocommande."&watch=yes"."\""; $message = (new \Swift_Message($subject)) ->setFrom
$langage = $request->request->get('langage-choisis');
$baturl = "href=\"http://localhost:8000/?keyview=".$keypreview."&order=".$numerocommande."&watch=yes"."\"";
$message = (new \Swift_Message($subject))
->setFrom('devdalvin@gmail.com')
->setTo( $destinataires)
->setBody(
$this->renderView('emails/contact.html.twig', [
'IdOrder' => $langage,
'messagegraphist' => $messagegraphist,
'messageinvoice' => $messageinvoice,
'baturl'=> $baturl,
'mailinstructions' => $mailinstructions,
'ordrefabrication' => $ordrefabrication,
'langage' => $langage,
]),
'text/html'
);
$mailer->send($message);
细枝模板
{% block email %}
<p>Bonjour,
<br/> Nos équipes ont terminées la préparation du BAT pour votre commande n°{{ IdOrder }}.
<br>Si votre commande comporte plusieurs articles, vous recevrez un BAT par article.
<br>Nous soulignons que nos dates de production et d'expédition courent à date de validation du présent BAT.<br>
{% if messagegraphiste is defined %}
<p><b>Précision de notre service graphique : </b></p>
<br>{{ messagegraphist }}<br>
{% endif %}
<br>{{ messageinvoice | raw}} <br>
<p><a style="color: white; padding: 20px 20px; background-color: #19692c" {{ baturl | raw}} ><b>VOIR LE BAT</b></a></p>
<br>{{ mailinstructions | raw}}<br>
Notre équipe vous souhaite une agréable journée.
</p>
{{ langage }}
{% endblock %}
{%block email%}
你好,
没有人质疑这项命令的目的。
《魔戒》命令普罗西斯的文章,VuneRevrz unBAT Par Par文章。
我们需要确定生产日期和出口日期,并确定生产日期和出口日期。
{%如果定义了messagegraphiste%}
notre服务决策图:
{{messagegraphist}}
{%endif%}
{{messageinvoice | raw}}
不可理解的是,如果没有这个错误,我不能添加额外的变量。但是,我将$langage作为变量'IdOrder'的值,它可以工作。但当我想在表中添加一个变量时:不可能。我还尝试给“langage”(比如$orderfabrication)赋予另一个值,但在“orderfabrication”起作用时,它仍然没有定义。有人有主意吗?谢谢:)谢谢你的帮助。但是,我已经考虑过清理缓存了。此外,这是我的电子邮件/contact.html.twig文件的全部内容。
转储还用于检查定义良好的$language的值(在contact.html.twig中使用$IdOrder进行检查)。
因此,我正在尝试清理计算机。您能提供控制器的完整代码吗?转储($langage)显示什么?@letibelim提供的代码足以演示问题请显示(完整的)电子邮件/contact.html.twig
。我怀疑您添加的变量可能不只是使用block,而是使用一些嵌套的block/include/embed/extend(还显示include/embedded模板)。@DarkBee这是一个毫无帮助的评论。即使是这样,它也可以帮助其他人避免对省略的代码进行假设。这个问题还没有答案,所以没有办法看到代码的其余部分。