Benefits for $html-link

2009-01-05 Thread gearvOsh

Are there any benefits, or behind the scenes magic for doing this:

$html-link('Link', array('controller' = 'users', 'action' =
'login', 'var'));

Compared to:

$html-link('Link', '/users/login/var/');

This also applies to anywhere else you build urls.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Benefits for $html-link

2009-01-05 Thread grigri

The main difference is reverse routing.

Defining a specific route syntax for a given controller/action and
using the array method will make the correct url.

Let's say you have

`Router::connect('/catalogue/c/*', array('controller' = 'categories',
'action' = 'view'));`
`Router::connect('/catalogue/p/*', array('controller' = 'products',
'action' = 'view'));`

Then you do

`$html-link('Link', array('controller' = 'products', 'action' =
'view', 123));`

The result will be `/catalogue/p/123`

Whereas if you do

`$html-link('Link', '/products/view/123')`

The result will be `/products/view/123`, which doesn't correspond to
your route.

hth
grigri

On Jan 5, 10:56 am, gearvOsh mileswjohn...@gmail.com wrote:
 Are there any benefits, or behind the scenes magic for doing this:

 $html-link('Link', array('controller' = 'users', 'action' =
 'login', 'var'));

 Compared to:

 $html-link('Link', '/users/login/var/');

 This also applies to anywhere else you build urls.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---