Thanks for clarifying regarding routes. 

Could you clarify what you mean "It be a simple `if` statement that calls one 
of two of the controllers `private` or `protected` methods which contain the 
login for wether the username is "Bob" or "BobsShop".

I have a UsersController and a ShopsController, the former handles the "Bob" 
username while the latter handles "BobsShop" username. So if i route the 
/:username url to my UsersController, how should I handle the logic for the 
"BobsShop" username? 

Thanks

> On Dec 20, 2014, at 9:09 PM, Andrew Lechowicz <[email protected]> 
> wrote:
> 
> Hi. I want to route a url to 2 controllers depending on some logic I define. 
> For example, if I have 2 usernames Bob and BobsShop, I want localhost/Bob to 
> route to my UsersController while localhost/BobsShop will route to my 
> ShopsController. I've thought of one way to accomplish this - by writing a 
> common ObjectsController that represents both a User and a Shop. Is there an 
> easier way via cake's routing mechanism? Thanks!
> 
> It seems like you might be confused as to what is a route and what is a 
> controller and what is a model. A route shouldn't contain any logic, it's 
> just the mapping of URL to Controller action. Or another way to put it is URL 
> to logic to perform. I would suggest if you have a route like `/:username` it 
> would route to a sigle controller action which then decided which logic to 
> perform. It be a simple `if` statement that calls one of two of the 
> controllers `private` or `protected` methods which contain the login for 
> wether the username is "Bob" or "BobsShop".
> 
> -- 
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
> 
> --- 
> You received this message because you are subscribed to a topic in the Google 
> Groups "CakePHP" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/cake-php/MpAJAUdAzJk/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to 
> [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/cake-php.
> For more options, visit https://groups.google.com/d/optout.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Reply via email to