我正尝试加载单独的移动视图并出现问题。 我可以让我的移动布局工作,但不是视图。cakephp无法加载移动视图
我用这个问题作为一个参考,我正在运行的CakePHP 2.1 CakePHP website mobile version
我不知道如何构建自己的移动的看法?
是/app/View/name/mobile/view.ctp还是 /app/View/mobile/name/view.ctp还是别的。我一直在试图解决这个问题。有什么建议么。
我AppController.php
过滤
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); } }
过滤后前(缩短)
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 ); } }
谢谢我没有意识到这本书是CakePHP书是不正确的... ... –