Tuesday, January 19, 2010

Re: Reverse routing syntax

You cant pass properties, and not use them in the router, and then
expect it to find them magically. The router parses the current URL in
the address bar and uses those values to pass into the action, unless
you have defined a route that matches and has static properties. You
either need to rethink your strategy, or use URL slugs.

On Jan 19, 12:56 am, jordicakephp <jordicake...@gmail.com> wrote:
> Good morning,
>
> I'm trying to implement the reverse routing capability to my app
> through the following two instructions.
>
> In my view:
>
> echo $html->link(
>         $province[0],
>         array('controller' => 'users',
>         'action' => 'directory',
>         'es-es',
>         '0',
>         'province' => $province[1]));
>
> In my routes.php:
>
> Router::connect('/empresas/:province',
>         array('controller'      => 'users', 'action' => 'directory',
> 'es-es', '0'),
>         array('pass'            => array('province')));
>
> This outputs the link /empresas/barcelona, as I expect and want, but
> my method directory($language = null, $searchBy = null, $item = null)
> receives the params 'barcelona', 'es-es' and '0'. However, I expect it
> to receive 'es-es', '0' and 'barcelona'; what is worse: I am not able
> to reorder the way in which those params are passed to my controller's
> action.
>
> My doubts:
>
> 1. How can I tell Cake "generate the link /empresas/barcelona and pass
> behind the scenes 'es-es', '0', 'barcelona' to directory.
>
> 2. Could anyone please explain me why my method receives those params
> in that order?
>
> God bless you.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate