0
votes

im having a problem with the CakePHP routing and the cookbook does not really help me out there.

im trying to route a parameter as a extension to an action. how can i do that without typing routes manually for each of my actions?

for example:
"users/settings/general" to UsersController::settings_general()
"users/settings/privacy" to UsersController::settings_privacy()
and so on

or should i just check in the settings action which parameter was given and call it from the controller? something like this

<?php
..
$sub_action = $this->request->params[0]
$this->settings_$subaction();
?>

1

1 Answers

0
votes

I do not think this is possible without writing a custom route class. Read this article how to use and write your own route classe: http://mark-story.com/posts/view/using-custom-route-classes-in-cakephp

I would recommend you to just declare a direct route for each action. Or are you going to have thousands of these actions?

You could also try to route all users/settings/* to a single action UsersController::settings() and get the parameter there and call $this->setAction('settings' . $param); See http://api20.cakephp.org/class/controller#method-ControllersetAction