我正在使用蛋糕电子邮件。
我习惯这样做(见视图变量)
$mail->from(authComponent::user('email'))
->to($this->Session->read('Site.email'))
->subject($this->Session->read('Site.name').' : New order No. '.$this->Basket->id)
->emailFormat('html')
->template('orderconfirmation')
->viewVars(array('title'=>'vlaue'))
->send();
我发送了很多数据作为几个博特产品的数据。它可以有一个产品,但可以有 10 个产品。
然后,我想发送一个数组$detailOfProducts这样,在我的邮件模板中,我将使用循环来显示内容。
I tried to change like this but without success
$mail->from(authComponent::user('email'))
->to($this->Session->read('Site.email'))
->subject($this->Session->read('Site.name').' : New order No. '.$this->Basket->id)
->emailFormat('html')
->template('orderconfirmation')
->viewVars($detailOfProducts)
->send();
你知道解决方案吗?
非常感谢
像将变量发送到您的视图一样发送它们..
$mail->from(authComponent::user('email'))
->to($this->Session->read('Site.email'))
->subject($this->Session->read('Site.name').' : New order No. '.$this->Basket->id)
->emailFormat('html')
->template('orderconfirmation')
->viewVars(array('details'=>$detailOfProducts))
->send();
您的视图代码将是..
<?php echo $detail[0]['Model']['field']; ?>
好的,我得到了答案!!对不起,我之前应该尝试过。
echo count($basketItems);
echo $basketItems[0]['name'];
然后使用 count() 的结果,我可以做一个循环来显示所有。我现在要试试这个。非常感谢您的帮助!!!
答案如下:(它进入了一个循环)
<?php echo $basketItems[$i]['name']; ?>
感谢您的帮助!!!