2011-05-15 40 views
1

尝试在CakePHP 2.0.0-dev中设置移动主题,但它不像1.3中那样工作。 2.0中的主题实现是否有任何更改?CakePHP 2.0.0-dev中的主题

结构如下:

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'; 
    } 
} 

点击主页上......但是,没有移动网站...只是正常的网站。没有错误,没有在调试或错误日志。没有错误,没有例外。没有。就好像主题已被弃用或什么。

任何想法的人?

回答

1

尝试:

$this->layout='mobile'; 

然后这应当由移动设备浏览显示布局。

+0

喜Gevious有一些更多的信息后。没有这样的布局。这不起作用。 – 2011-05-17 11:23:29

+0

你需要创建你自己的布局,称为移动(或任何你喜欢的) – Gevious 2011-05-17 15:37:02

1

解决!

寻找位于cake/lib /视图/ theme.php后,我读了这一点:

...您可以设置$this->theme$this->viewClass = 'Theme' ...

public function beforeRender() 
{ 
    if ($this->RequestHandler->isMobile()) { 
     $this->viewClass = 'Theme'; 
     $this->theme = 'mobile'; 
    } 
} 

所以,看起来像2.0版本中的变化很小,从$ this-> view$ this-> viewClass

现在工作!