Re: ambiguous routes

2009-07-16 Thread mark_nsx

Thank you very much Piotr! I'll give that a try tomorrow morning.
Cheers!

On Jul 16, 10:01 pm, Piotr Kilczuk  wrote:
> Hello,
>
> I highly dislike working with routes, but there are few points where
> it can break.
>
> 1. What is the difference between the two rules you supplied? Any
> chance that the 2nd route will be ever used?
>
> 2. I suppose you use Router::connect not $Route->connect, just a typo here...
>
> 3. As far as I understand your beforeFilter(), it WILL make a
> redirection loop every time, since always 1st route is used and for
> some reason if condition is never met.
>
> What I would suggest, is to make a action (no beforeFilter), which
> would dispatch the request to proper method depending on wheter the
> url argument is a valid user name, valid group name or neither
> ($this->cakeError probably).
>
> Hope this is any help to you.
>
> Regards,
> Piotr
--~--~-~--~~~---~--~~
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: ambiguous routes

2009-07-16 Thread Piotr Kilczuk

Hello,

I highly dislike working with routes, but there are few points where
it can break.

1. What is the difference between the two rules you supplied? Any
chance that the 2nd route will be ever used?

2. I suppose you use Router::connect not $Route->connect, just a typo here...

3. As far as I understand your beforeFilter(), it WILL make a
redirection loop every time, since always 1st route is used and for
some reason if condition is never met.

What I would suggest, is to make a action (no beforeFilter), which
would dispatch the request to proper method depending on wheter the
url argument is a valid user name, valid group name or neither
($this->cakeError probably).

Hope this is any help to you.


Regards,
Piotr

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



ambiguous routes

2009-07-15 Thread mark_nsx

Hi there,

The application im currently working on allows Users and Groups to
select their unique personalized URLs i.e. www.site.com/my_own_url. I
have specified the routes like so:

$Route->connect('/:user_url', array('controller' => 'users', 'action'
=> 'view', 'url' => ':user_url'), array('user_url' => '[\w]+'));

$Route->connect('/:group_url', array('controller' => 'groups',
'action' => 'view', 'url' => ':group_url'), array('group_url' => '[\w]
+'));

The beforeFilter() method in the Users controller first checks if
there is user with that URL, otherwise it will be passed on to the
Groups controller. So in the Users controller's beforeFilter() method
I have:

function beforeFilter() {
If user with URL exists -> display view() page
Else hand it to the Groups controller ($this->redirect('/' . $this-
>params['user_url']))
}

The problem I'm having is a redirect loop. Of course the first route
will always catch whatever it is. If I could somehow select which
route to activate.. and I don't have the luxury of adding prefixes to
the URL.. Thanks for all your help!
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---