开发者

Cake PHP route controller/action to other controller/action

开发者 https://www.devze.com 2023-03-23 18:58 出处:网络
How can I make cakePHP go to ef_users/logout when I click the users/logout link? Thanks in advance EDIT

How can I make cakePHP go to ef_users/logout when I click the users/logout link?

Thanks in advance

EDIT

This doesn't seem to work

Router::connect('/users/:开发者_StackOverflow社区action/*', array('controller' => 'ef_users', 'action' => 'logout'));


A couple of options:

  • Make the link point to the correct place in the first place
  • Use routing: http://book.cakephp.org/view/945/Routes-Configuration
  • Redirect the user with $this->redirect( url ): http://book.cakephp.org/view/982/redirect


If in doubt, just use as precise route as possible and put it near the top of the list

Router::connect('/users/logout', array('controller' => 'ef_users', 'action' => 'logout'));


You might also consider using logoutRedirect which will still log the user out using the standard CakePHP logout function then redirect the user to your ef_users logout action.

$this->Auth->logoutRedirect = array('controller' => 'ef_users', 'action' => 'logout');

More information at: http://book.cakephp.org/view/1271/logoutRedirect

0

精彩评论

暂无评论...
验证码 换一张
取 消