This might be beside the point, and I can't think of a way to do it as
you've described without hard coding, but (and it's a big but),

why do you have hardcoded controllers for each game/team or game/
match? and given that you do why not hard code the route?

It would seem more logical (altough there's probably a good reason you
haven't mentioned) to have separate "teams" controller and "matches"
controller, and pass it the "game" as a param.
Then you could route:

Router::connect('/:game/teams', array('controller'=>'teams',
'action'=>'index'),array('game'=>'[a-z]+'));
Router::connect('/:game/matches', array('controller'=>'matches',
'action'=>'index'),array('game'=>'[a-z]+'));

and your controller could do something like

function index(){
  switch($this->params['game']){
    case "ping" :
      // do ping thing
      break;
    case "catan":
      // do catan thing
      break;
    ...
    default:
      // no match to game
      $this->redirect($somewhere);
  }
}

On Jun 25, 2:54 pm, benjam <[EMAIL PROTECTED]> wrote:
> I have a question about a custom route and was wondering if it's
> possible, and if it is, how?
>
> I have some controllers for a game match site named the following:
> foos_teams
> foos_matches
> chess_matches
> ping_teams
> ping_matches
> catan_matches
>
> and I would like to be able to access them by going to the following
> (respectively):
> /foos/teams
> /foos/matches
> /chess/matches
> /ping/teams
> /ping/matches
> /catan/matches
>
> How might I do this?  And I don't want to hard code each of them, I
> could, but I'd like to know if there is a better way that will work
> for new games and pages as soon as they are added without any further
> route building.
>
> Thanks, I know it's a tricky one.  My not even be possible, but any
> help you could give me is appreciated.
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to