howrad
howrad

Reputation: 1086

CakePHP - Use HtmlHelper::link with URL title

I want CakePHP to make a link with a title that is the full URL that the link points to.

Like this: http://example.com/users/login
Instead of this: Login

I tried using a null title:

echo $this->Html->link(null, array('controller' => 'users', 'action' => 'login'));

and a blank title:

echo $this->Html->link('', array('controller' => 'users', 'action' => 'login'));

but neither worked. Do I need to use a different function?

Upvotes: 0

Views: 296

Answers (1)

mark
mark

Reputation: 21743

Why didnt you try the only obvious one? Passing in an URL to the title (first param)?

echo $this->Html->link(array('controller' => 'users', 'action' => 'login'));

If it needs to be the full URL, you might have to do it in two steps, though:

$url = $this->Html->url(array('controller' => 'users', 'action' => 'login'), true);
echo $this->Html->link($url);

Upvotes: 1

Related Questions