$prefix_array = array('admin', 'marketing');
if ($this->Auth->user() AND in_array(@$this->params['prefix'], $prefix_array)) { $this->layout = 'admin'; } else { $this->lay开发者_如何学JAVAout = 'default';}
-where should i do it in bootstrap or app_controller?
-how can i dynamically read prefix from DB, set to $prefix_array -write them to Configure::write('Routing.prefixes')In your app controller, just load the prefixes:
var $uses = array('Prefix');
function beforeFilter() {
$prefixes = $this->Prefix->find('list');
if($this->Auth->user() && in_array($this->params['prefix'], $prefixes) {
$this->layout = 'admin';
}
}
精彩评论