Sunday, April 4, 2010

Re: Named parameters ruins my custom routing

Strangely enough, after taking out this line:
//Router::connect('/projects/:project_id/
issues/:action/:Ff0/:Fo0/:Fv0', array('controller' => 'issues',
'project_id' => null, 'Ff0' => null, 'Fo0' => null, 'Fv0' => null),
array('project_id' => '[a-zA-Z0-9\-]+', 'Ff0' => '[a-zA-Z0-9\-]+',
'Fo0' => '[a-zA-Z0-9\-]+', 'Fv0' => '[a-zA-Z0-9\-]+'));
Which isn't needed due to the wildcard used above, it still failed..
Until I put this line in:
Router::connectNamed(array('Ff0', 'Fo0', 'Fv0'));

Then, my question is as follows:

Is it possible to use wildcards in connectNamed?

Like this? ->
Router::connectNamed(array('Ff?', 'Fo?', 'Fv?'));

On Apr 4, 6:46 pm, jacmoe <jac...@mail.dk> wrote:
> Hi bakers :)
>
> I have an app which uses routing to produce links like this:http://localhost/projects/bugitor/issues/index
> Instead of this:http://localhost/issues/index/project_id:bugitor
>
> It works - as long as I don't use extra named parameters. :(
>
> I can't figure out what's wrong with it.
>
> I am using - or trying to use - a filter component/helper which uses
> named parameters for passing the filters around.
> They are variable in numbers, and looks like this:
> Ff0:Issue.id/Fo0:equals/Fv0:515
>
> The problem is that when I try to use the filter form from this page:http://localhost/projects/bugitor/issues/index
> It takes me to this instead:http://localhost/issues/index/project_id:bugitor/Ff0:Issue.id/Fo0:equ...
>
> My mess in routes.php looks like this:
> Router::connect('/projects/:project_id/changesets/:action/*',
> array('controller' => 'changesets', 'project_id' => null),
> array('project_id' => '[a-zA-Z0-9\-]+'));
> Router::connect('/projects/:project_id/issues/:action/*/:Ff0/:Fo0/:Fv0/
> *', array('controller' => 'issues', 'project_id' => null, 'Ff0' =>
> null, 'Fo0' => null, 'Fv0' => null), array('project_id' => '[a-zA-
> Z0-9\-]+', 'Ff0' => '[a-zA-Z0-9\-]+', 'Fo0' => '[a-zA-Z0-9\-]+', 'Fv0'
> => '[a-zA-Z0-9\-]+'));
> Router::connect('/projects/:project_id/issues/:action/*',
> array('controller' => 'issues', 'project_id' => null, '*' => null),
> array('project_id' => '[a-zA-Z0-9\-]+', '*' => '[a-zA-Z0-9\-]+'));
> Router::connect('/projects/:project_id/members/:action/*',
> array('controller' => 'members', 'project_id' => null),
> array('project_id' => '[a-zA-Z0-9\-]+'));
> Router::connect('/projects/:project_id/issues', array('controller' =>
> 'issues', 'action' => 'index'));
> Router::connect('/projects/:project_id', array('controller' =>
> 'projects', 'action' => 'view'), array('project_id' => '[a-zA-Z0-9\-]
> +'));
> Router::connect('/projects/:project_id/:action/*', array('controller'
> => 'projects', 'project_id' => null), array('project_id' => '[a-zA-
> Z0-9\-]+'));
> Router::connect('/projects', array('controller' => 'projects',
> 'action' => 'index'));
> Router::connect('/issues/reply/*', array('controller' => 'issues',
> 'action' => 'reply'), array('pass' => array('project_id', 'id')));
> Router::connect('/projects/add', array('controller' => 'projects',
> 'action' => 'add'));
> Router::connect('/projects/index', array('controller' => 'projects',
> 'action' => 'index'));
> Router::connect('/issues/index/*', array('controller' => 'issues',
> 'action' => 'index'));
> Router::connect('/issues/add/*', array('controller' => 'issues',
> 'action' => 'add'));
> Router::connect('/issues/view/*', array('controller' => 'issues',
> 'action' => 'view'));
>
> To be honest, I am not sure what order it should go in, but .. :)
> As you can see, I tried to create a route with all three parameters,
> but that isn't working.
>
> Anything I am overlooking here?
> I also tried just defining the three parameters as named parameters:
> Router::connectNamed(array('Ff0', 'Fo0', 'Fv0'));
> But, again: fail.
>
> I am using CakePHP 1.3.
>
> Any hints would be welcomed! :)

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

To unsubscribe, reply using "remove me" as the subject.

No comments: