CakePHP管理面板和前端

时间:2011-10-02 15:30:05

标签: cakephp

我是CakePHP的新手。这些天,我创建了一个类似hotscripts的应用程序。我需要一个网站管理员管理面板为公众访问者添加新文章/应用和前端。

我正在为此寻找解决方案。我已经将router_prefix改为admin。例如,在CategoriesController中。

public function admin_add() {

}

public function view($id) {
}

据我所知,这是解决方案之一。在CategoriesController中,我设置了

$this->Auth->allow('view');

以便访问者无需登录即可访问此页面。我的问题是,这真的是管理员和前端产品的解决方案吗?

提前致谢!

        public $components = array(
        'Auth' => array(
            'authorize' => 'controller',
            'loginRedirect' => array(
                'admin' => true,
                'controller' => 'dashboards',
                'action' => 'index',
            ),
            'loginError' => 'Invalid account specified',
            'authError' => 'No Permission',

        ),

谢谢Anh Pham !!!我按照你的建议,将此代码添加到AppController。我现在不知道adminRramirect中的admin param意味着什么?你能解释一下吗?

2 个答案:

答案 0 :(得分:2)

is this really a solution for admin and front product? 

是的,您必须将$this->Auth->allow('view');放在beforeFilter中,并且记得在过滤器之前调用app控制器(很可能是在那里设置了Auth设置)。所以它看起来像这样:

function beforeFilter() {
    parent::beforeFilter();
    $this->Auth->allow('view');
}

编辑:'admin'有前缀:它表示登录后,它将重定向到yoursite.com/admin/dashboards。如果您未设置admin => true,则会重定向到yoursite.com/dashboards。使用前缀进行基于组的访问控制只是一种常见做法。 (稍后,如果您有多个登录用户组:admin,sub-admin等,则需要设置Auth以限制访问级别;但这非常简单。)

答案 1 :(得分:0)

我建议你研究一下Croogo。这是一个基于CakePHP构建的CMS。

相关问题