如何从数据库动态写入路由前缀
我有带有前缀的数据库表,并且需要它们在 app_controller beforeFilter 中可读 $prefix_array = array('admin', '营销');
if ($this->Auth->user() AND in_array(@$this->params['prefix'], $prefix_array)) { $this->layout = 'admin'; } } else { $this->layout = 'default';}
- 我应该在 bootstrap 或 app_controller 中哪里做?
-如何从数据库动态读取前缀,设置为 $prefix_array
-将它们写入Configure::write('Routing.prefixes')
i have db table with the prefixes and need them to be readable in app_controller beforeFilter
$prefix_array = array('admin', 'marketing');
if ($this->Auth->user() AND in_array(@$this->params['prefix'], $prefix_array)) { $this->layout = 'admin'; } else { $this->layout = '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: