我遇到了在CakePHP-project中创建管理部分的概念。 (版本2.3.5)
I'm struggling with the concept of creating an admin section in CakePHP-project. (version 2.3.5)
我已取消注释Config / core.php中的行:
I have uncommented the line in Config/core.php:
Configure::write('Routing.prefixes', array('admin'));我已经在Config / routes.php中添加了这一行:(就像他们在CakePHP Cookbook。)
I have added the line in Config/routes.php: (Just as they advice to do in CakePHP cookbook.)
Router::connect('/admin', array('controller'=>'pages', 'action'=>'index','admin' => true));在AppController.php中有以下内容:
In AppController.php I have the following:
public $components = array( 'Session', 'Auth' => array( 'loginRedirect'=>array('controller'=>'pages','action'=>'index', 'admin'=>true), 'logoutRedirect'=>array('controller'=>'pages','action'=>'display','home'), 'authError'=>'you have no access.', 'authorize'=>array('Controller') ) );然后我添加了一个布局视图/ Pages / admin_index.ctp这是我想重定向登录后。我设法让我的登录工作在UsersController.php。
Then I have added a layout View/Pages/admin_index.ctp which is where I want to be redirected after login. I managed to get my login working in UsersController.php.
所以问题是,我应该在AppController.php中重定向,以获取我的登录管理员到admin_view?我相信loginRedirect是有点破坏。
So the question is, where should I redirect in AppController.php to get my logged admin to the admin_view? I believe that loginRedirect is somehow broken..
我研究了一些关于这个主题的教程,但我发现只有这个YouTube视频www.youtube/watch?v=zvwQGZ1BxdM 所有其他教程似乎都与CakePHP的早期版本有关。
I have studied some tutorials on this subject but I have found only this Youtube-video www.youtube/watch?v=zvwQGZ1BxdM All other tutorials seem to be concerning earlier versions of CakePHP.
推荐答案我想你可以在AppController中设置一个loginAction,然后在这个动作中你可以这样做:
I guess you could set a loginAction in AppController and then inside this action you could do:
$this->redirect(array('controller'=>'someController','action'=>'someAction','admin'=>true));更多推荐
CakePHP管理部分路由和重定向
发布评论