我是一个使用cakephp-3.0的新手。
我打算根据用户的浏览器/代理显示不同的模板-视图。在cakephp2.x中,代码可能如下所示:
if ($this->DisplayModeService->hasSpViewSupport()) {
App::build([
'View' => [APP . 'View/SmartPhone/', APP . 'View/'],
]);
}但在cakephp3.0中,它是用app.php编写的:
return [
'App' => [
'paths' => [
'templates' => [
APP . 'Template' . DS . 'SmartPhone' . DS,
APP . 'Template' . DS,
],
],
],
];但我只想在页面具有smartPhone版本时更改模板路由。在上面的情况下,它无论如何都会跳到SP版本。(因为我想在相同的页面上保留相同的名称)
例如:
/Template/SmartPhone/profile.ctp,/Template/profile.ctp。(有SP/PC版本)
/Template/news.ctp (仅限PC版)
这有可能吗?
发布于 2015-06-17 20:35:42
你最好使用$this->request->is('mobile')和主题
https://stackoverflow.com/questions/30886573
复制相似问题