2011-10-02 88 views
0

我是CakePHP的新手。這些日子裏,我創建了一些像hotscripts一樣的應用程序。我需要一個管理面板讓網站管理員爲公衆訪問者添加新的文章/應用和前端。CakePHP管理面板和前端

我正在尋找解決方案。我已經讀取了router_prefix爲admin。例如,在CategoriesController中。

public function admin_add() { 

} 

public function view($id) { 
} 

據我所知,這是解決方案之一。在分類控制器中,我設置了

$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。我現在不知道管理員參數在loginRedirect中的含義是什麼?你能向我解釋這個嗎?

回答

2
is this really a solution for admin and front product? 

是的,你將不得不把$this->Auth->allow('view');在beforeFilter,並記住調用beforeFilter也(很有可能你設置的驗證設置那裏)的應用程序控制器。所以它會是這樣的:

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

編輯:「系統管理員」有前綴:它意味着在登錄後,會重定向到yoursite.com/admin/dashboards。如果您未設置admin => true,則會重定向到yoursite.com/dashboards。使用基於組的訪問控制的前綴是一種常見的做法。 (稍後,如果您有超過1組登錄用戶:admin,sub-admin等,則需要設置Auth來限制訪問級別;但這非常簡單)。

+0

非常感謝。編輯版中的另一個問題。 – Ruiwant

0

我建議你看看Croogo。這是一個基於CakePHP構建的CMS。

+0

謝謝。我已經下載了它。真棒! – Ruiwant