Issue
I have added a function to check for language parameter to my AppController
function beforeFilter(){
if(Configure::read('Config.language') == 'ara'){
$this->layout = 'rtl-layout';
} else {
$this->layout = 'ltr-layout';
}
}
but it doesn't work in my other controllers ?
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());
}
}
Please help me, it's driving me nuts.
Solution
I forgot to call the base class' beforeFilter()
since I was overloading it in my 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());
}
}
Answered By - Nasreddine
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.