Nas*_*ine 2 php cakephp cakephp-1.3
我添加了一个函数来检查我的AppController的语言参数
function beforeFilter(){
if(Configure::read('Config.language') == 'ara'){
$this->layout = 'rtl-layout';
} else {
$this->layout = 'ltr-layout';
}
}
Run Code Online (Sandbox Code Playgroud)
但它在我的其他控制器中不起作用?
class ImagesController extends AppController {
var $name = 'Images';
var $helpers = array('TinyMCE');
function beforeFilter(){
if(!isset($this->params['admin'])) {
$this->Session->setFlash(__('Access denied.', true));
$this->redirect(array('controller'=>'users','action'=>'login','admin'=>false));
exit();
}
}
function index() {
$this->Image->recursive = 1;
$this->set('images', $this->paginate());
}
}
Run Code Online (Sandbox Code Playgroud)
请帮助我,这让我疯了.
我忘记打电话给基地了,beforeFilter()因为我在我的课上超载了ImagesController
class ImagesController extends AppController {
var $name = 'Images';
var $helpers = array('TinyMCE');
function beforeFilter(){
parent::beforeFilter(); // <-- here
if(!isset($this->params['admin'])) {
$this->Session->setFlash(__('Access denied.', true));
$this->redirect(array('controller'=>'users','action'=>'login','admin'=>false));
exit();
}
}
function index() {
$this->Image->recursive = 1;
$this->set('images', $this->paginate());
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1655 次 |
| 最近记录: |