我正在尝试加载单独的移动视图并遇到问题。我可以让我的移动布局工作,但不能让视图工作。
我使用这个问题作为参考,我正在运行 cakephp 2.1 CakePHP 网站移动版
我不确定如何构建我的移动视图?
是 /app/View/name/mobile/view.ctp 还是 /app/View/mobile/name/view.ctp 或其他东西。我一直在兜圈子试图弄清楚这一点。有什么建议么。
我的 AppController.php
过滤前
公共函数 beforeFilter() {
/* 移动布局测试 */
if ($this->request->isMobile()){
$this->is_mobile = true;
$this->set('is_mobile', true );
$this->autoRender = false;
} 别的 {
$this->set('is_mobile', false );
}
}
过滤后(缩短)
函数后过滤器(){
$view_file = file_exists(
“/var/www”。
$this->webroot 。
“应用程序” 。DS 。
'看法' 。DS 。
$this->name 。DS 。
'移动的/' 。
$这个->动作。
'.ctp'
);
$layout_file = file_exists(
“/var/www”。
$this->webroot 。
“应用程序” 。DS 。
'看法' 。DS 。
“布局”。DS 。
'移动的/' 。
$this->布局。
'.ctp'
);
如果($view_file || $layout_file){
$这个->渲染(
$this->动作,
($layout_file?'mobile/':'').$this->layout,
($view_file?'mobile/':'').$this->action
);
}
}