0

我正在尝试在我的 HTML 电子邮件模板中生成链接:

<?php echo $html->link('Find a shop', array('controller' =>'shop', 'action' => 'search'), array('escape'=>false,'target'=>'_blank')); ?>

我希望有一个链接,例如:http://shopexample.localhost/shop-search但只生成了shop-search而没有http://shopexample.localhost

控制器的逻辑是使用 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 版。

谢谢

4

1 回答 1

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

于 2013-06-27T16:24:09.693 回答