CakePHP Routes: Messing With The MVC
Posted
by thesunneversets
on Stack Overflow
See other posts from Stack Overflow
or by thesunneversets
Published on 2010-04-23T23:06:30Z
Indexed on
2010/04/23
23:13 UTC
Read the original article
Hit count: 273
So we have a real-estate-related site that has controller/action pairs like "homes/view", "realtors/edit", and so forth. From on high it has been deemed a good idea to refactor the site so that URLS are now in the format "/realtorname/homes/view/id", and perhaps also "/admin/homes/view/id" and/or "/region/..."
As a mere CakePHP novice I'm finding it difficult to achieve this in routes.php. I can do the likes of:
Router::connect('/:filter/h/:id', array('controller'=>'homes','action'=>'view'));
Router::connect('/admin/:controller/:action/:id');
But I'm finding that the id is no longer being passed simply and elegantly to the actions, now that controller and action do not directly follow the domain. Therefore, questions:
- Is it a stupid idea to play fast and loose with the /controller/action format in this way?
- Is there a better way of stating these routes so that things don't break egregiously?
- Would we be better off going back to subdomains (the initial method of achieving this type of functionality, shot down on potentially spurious SEO-related grounds)?
Many thanks for any advice! I'm sorry that I'm such a newbie that I don't know whether I'm asking stupid questions or not....
© Stack Overflow or respective owner