Question

I'm trying to generate links in my HTML email template:

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

I expect a link like: http://shopexample.localhost/shop-search but there is generated only shop-search without http://shopexample.localhost

Controller's logic is using 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 helper is included. I'm using CakePHP version 1.3.

Thanks

Was it helpful?

Solution

try to use

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

so, wrap routing array into Router::url with true paramter, which will return full url

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top