-3

As of my knowledge these both are used for creating links :

What is the main difference between $this->Html->url and $this->Html->link in Cakephp?

Is there any performance issues occurs for using these?

What if i want to open link in new tab using "$this->Html->url"

What i tried :

<?php echo $this->Html->url($item['News']['link'],array('target'=>'_blank', 'escape' => false)); ?>

but its not working. open link in same tab.

Thanks in advance.

Isaac
  • 983
  • 1
  • 7
  • 13
s4suryapal
  • 1,880
  • 1
  • 18
  • 26
  • 1
    That is like asking what the difference between apples and trees are. The other requires the other to exist ;) in this case url() is needed for link() to exist and function. – mark Sep 28 '14 at 11:17

2 Answers2

0

Well, according to CakePHP Documentation, the HTML->url takes two arguments, the 2nd one is a boolean while the first is a routing array. Try this:

<?php echo 
    $this->Html->url(
             array(
                   'href' => $item['News']['link'],
                   'target' => '_blank',
                   'escape' => false
                   ),
             false     // Second argument, true means prepend the path of my site before the link while false means don't prepend
     ); ?>

References:

  1. http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html#HtmlHelper::url
  2. http://book.cakephp.org/2.0/en/appendices/glossary.html#term-routing-array
Ahamad I Milazi
  • 479
  • 3
  • 14
0

This is what the $this->Html->link() method is for. It takes an array of options as parameters to do this.

Ende Neu
  • 15,581
  • 5
  • 57
  • 68