gdm
gdm

Reputation: 7930

CakePhp HtmlHelper link method

If I write

debug($this->Html->link('pippo',array('controller'=>'customers','action'=>'index')));

the link is good

'<a href="<<document_root>/index">pippo</a>'

But If I write

   debug($this->Html->link('pippo','customers/index'));

it prints :

'<a href="/www/customers/customers/index">pippo</a>'

contrary to what the manual says. Why?

Upvotes: 0

Views: 41

Answers (1)

floriank
floriank

Reputation: 25698

The book does not say customers/index but /customers/index. Notice the / in front.

Also never use string notation for links that point to your application but the array notation. Routing doesn't work if you use strings plus the router has to decompile the string to array which can be a little overhead if you have plenty of links on a page.

So stick the array instead of the string.

Upvotes: 2

Related Questions