I am trying to load a separate mobile view and having a problem. I can get my mobile layout to work but not the view.
I was using this question as a reference and I am running cakephp 2.1 CakePHP website mobile version
I am not sure how to structure my mobile views?
Is it /app/View/name/mobile/view.ctp or /app/View/mobile/name/view.ctp or something else. I have been going in circles trying to figure this out. Any suggestions.
My AppController.php
Before Filter
public function beforeFilter() {
/* mobile layout testing */
if ($this->request->isMobile()){
$this->is_mobile = true;
$this->set('is_mobile', true );
$this->autoRender = false;
} else {
$this->set('is_mobile', false );
}
}
After Filter (shortened)
function afterFilter() {
$view_file = file_exists(
"/var/www" .
$this->webroot .
"app" . DS .
'View' . DS .
$this->name . DS .
'mobile/' .
$this->action .
'.ctp'
);
$layout_file = file_exists(
"/var/www" .
$this->webroot .
"app" . DS .
'View' . DS .
'Layouts' . DS .
'mobile/' .
$this->layout .
'.ctp'
);
if($view_file || $layout_file){
$this->render(
$this->action,
($layout_file?'mobile/':'').$this->layout,
($view_file?'mobile/':'').$this->action
);
}
}