我正在尝试在HTML电子邮件模板中生成链接:
<?php echo $html->link('Find a shop', array('controller' =>'shop', 'action' => 'search'), array('escape'=>false,'target'=>'_blank')); ?>
我希望有一个类似于http://shopexample.localhost/shop-search的链接,但只生成商店搜索,但没有http://shopexample.localhost
Controller的逻辑正在使用EmailComponent
$this->Email->to = $to;
$this->Email->subject = $subject;
$this->Email->replyTo = $replyTo;
$this->Email->from = "Me <".$from.">";
$this->Email->template = $template;
$this->Email->body = $body;
$this->Email->sendAs = 'html';
$this->Email->smtpOptions = Configure::read('SMTP.Options');
$this->Email->delivery = 'smtp';
if($to!=null){
if($this->Email->send()){
$this->Email->reset();
}
}
包含HTML帮助器。我正在使用CakePHP 1.3版。
由于
答案 0 :(得分:1)
尝试使用
<?php
echo $html->link('Find a shop',
Router::url(array('controller' =>'shop', 'action' => 'search'), true),
array('escape'=>false,'target'=>'_blank'));
?>
所以,使用true参数将路由数组包装到Router :: url中,这将返回完整的URL