Jquery mobile Cakephp 2.x移动主题和前缀
我目前正在为我的一个应用程序添加自定义移动布局 AppController.phpJquery mobile Cakephp 2.x移动主题和前缀,jquery-mobile,cakephp-2.1,prefix,Jquery Mobile,Cakephp 2.1,Prefix,我目前正在为我的一个应用程序添加自定义移动布局 AppController.php if ($this->request->is('mobile')) { //$this->viewClass = 'Theme'; $this->theme = 'Mobile'; } else { $this->theme = Configure::read('App.theme'); } 工作很好。。让jquery mobile现在完美地运行。 然而,我想在
if ($this->request->is('mobile')) {
//$this->viewClass = 'Theme';
$this->theme = 'Mobile';
} else {
$this->theme = Configure::read('App.theme');
}
工作很好。。让jquery mobile现在完美地运行。
然而,我想在控制器中开发单独的功能,因为主网站确实从DB收集了比移动版本需要的更多的数据
所以我想到了一种方法,比如,if request mobile=>set this prefix=mobile或者类似的方法?在控制器中允许单独的移动功能
有什么建议吗
另外,我想在页面加载时设置一个参数,比如,你想查看手机版本吗?是/否。如果否=>show mobile=false,如果是=>show mobile=true。最好是通过某种弹出窗口(如tapatalk论坛应用程序通知)
感谢您在这方面的帮助:)
-Tom就像您在AppController中使用$this->request->is('mobile'),您可以在所有控制器中使用相同的方法,并根据请求类型执行逻辑,这是实现目标的好方法
第二
您可以创建一个元素,询问用户“是否移动?”
在登录页控制器中(或者如果您希望在每个页面中进行此检查,例如,如果用户登录到具有其他站点链接的特定页面。然后在AppController beforeFilter()中执行此操作),您可以检查如下值:
$mobilePref = Configure::read('Config.mobilePreference');
if($mobilePref){
$this->set('showMobileElement', true);
} else {
if($mobilePref == 'Mobile'){
$this->set('showMobileLayout', true);
} else {
$this->set('showMobileLayout', false);
}
}
在您的布局中,只需检查$showMobileLayout,如果为真,则显示移动布局,如果为假,则显示正常布局。
如果未设置,则选中$showMobilePref,如果为真,则调用“Mobile or not?”元素。根据元素中用户的答案,您可以设置
Configure::write('Config.mobilePreference', true); //or false, depending on answer
我想大概就是这样吧。当然,如果您正在验证用户,您应该保存用户的选择,并在用户下次登录时记住它