我设计了一个在线购物网站,其中包含了“比较产品”选项。
因此,在单击compare按钮之后,将显示一个可取消的警告框,其中包含消息"Product Successfully to Compare“。但是,我现在需要给用户一个链接,让他们点击并直接转到比较页面。
Like“产品成功添加到对比中,点击此处即可查看”。
但是,我不知道如何添加链接。
我使用的代码是,
$this->Session->setFlash(__('Product Successfully Added to Compare '), 'success');请告诉我如何在消息中添加链接。
发布于 2014-11-13 15:49:11
我只是在其他链接中发现了这一点,并且工作正常。感谢您的努力和回答。
尝尝这个。
1)在app/views/elements中创建新元素session_flash_link.ctp。
2)在session_flash_link.ctp中添加了以下代码
<div id="flashMessage" class="message">
<?php
echo $message;
echo $this->Html->link($link_text, $link_url, array("escape" => false));
?>
</div>3)控制器中的代码:
$this->Session->setFlash("Shop has been successfully saved. ", "session_flash_link", array(
"link_text" => "Return to Shop Management »",
"link_url" => array(
"controller" => "shops",
"action" => "manage",
"admin" => true
)
));发布于 2014-11-13 15:07:57
使用以下命令:
// access the html helper
$Html = (new View($this))->loadHelper('Html');
// use it to generate a link
$resend = $Html->link(__('resend'), array(
'controller' => 'users',
'action' => 'resend',
));
// sprintf to insert the link to your standard message text!
$this->Session->setFlash(sprintf(_("Product Successfully Added to Compare."), $resend));发布于 2014-11-13 15:10:31
更简单、更简单的方法,甚至不需要使用helper
$this->Session->setFlash('Page not found <a href="'. Router::url(array('controller' => 'users', 'action' => 'login')) .'"> login here</a>', 'error');https://stackoverflow.com/questions/26902697
复制相似问题