CakePHP 2.0.0-dev 中的主题
尝试在 CakePHP 2.0.0-dev 中设置移动主题,但它不像 1.3 中那样工作。 2.0 中的主题实现有任何变化吗?
结构如下:
app/views/themed/mobile/layouts/default.ctp
app/views/themed/mobile/pages/home.ctp
然后在 app/app_controller.php 中:
public function beforeRender()
{
if ($this->RequestHandler->isMobile()) {
$this->view = 'Theme';
$this->theme = 'mobile';
}
}
点击主页...但没有移动站点...只是普通站点。没有错误,调试或错误日志中没有任何内容。没有错误,没有例外。没有什么。好像主题已被弃用或其他什么。
有人有什么想法吗?
Trying to set up a mobile theme in CakePHP 2.0.0-dev, but it isn't working as it did in 1.3. Have there been any changes to the themes implementation in 2.0?
Structure as follows:
app/views/themed/mobile/layouts/default.ctp
app/views/themed/mobile/pages/home.ctp
Then in app/app_controller.php:
public function beforeRender()
{
if ($this->RequestHandler->isMobile()) {
$this->view = 'Theme';
$this->theme = 'mobile';
}
}
Hit the home page... But no mobile site... Just the normal site. No errors, nothing in debug or error logs. No errors, no exceptions. Nothing. As if themes have been deprecated or something.
Any ideas anyone?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
try:
当移动设备浏览时,应该会显示布局。
try:
That should then display the layout when browsed to by a mobile device.
解决了!
查看 cake/libs/view/theme.php 后,我读到了以下内容:
所以,看起来 2.0 版本略有变化变量名称从 $this->view 到 $this->viewClass。
现在可以工作了!
Solved!
After looking in cake/libs/view/theme.php, I read this:
So, looks like a slight change in version 2.0 to the variable name from $this->view to $this->viewClass.
Works now!
如果有人对此有进一步的问题,我在 http://blog.ergatides.com/web-design/themes-in-cakephp-2-0-0/
If anyone has further issues with this, I have a post with some more information at http://blog.ergatides.com/web-design/themes-in-cakephp-2-0-0/