I still have problems with this.

The issue is that named parameters ruins my routed parameters.
Which it shouldn't.

I see that Mark Story intends to support a variable amount of named
parameters for CakePHP 2.0:
http://cakephp.lighthouseapp.com/projects/42649/tickets/11-modifyremove-routerconnectnamed

But I can't wait that long! :)

How do you guys do this?
I can define all my named parameters in routes.php, of course.
There a quite a lot, as it's for filtering.
I am considering using another approach: instead of named parameters,
I'd use url parameters.
So /projects/project_name/issues/index/Issue.tracker_id:2 becomes /
projects/project_name/issues/index/?Issue.tracker_id=2

This is my router connect line:
Router::connect('/projects/:project_id/issues/:action/*',
array('controller' => 'issues', 'project_id' => null),
array('project_id' => '[a-zA-Z0-9\-]+'));

Even when specifying named parameters, the router refuses to
recognise :project_id as a routing parameter. It thinks it's a named
parameter..
Is this a bug?
Or am I doing it wrong?

On Apr 4, 7:50 pm, jacmoe <[email protected]> wrote:
> 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 <[email protected]> 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 [email protected]
To unsubscribe from this group, send email to
[email protected] 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.

Reply via email to