themes,如何修改themes路径,如何在controller中激活指定的thems

因为站点中存在 站点皮肤 以及 站点中存在 "我的店铺"这个功能 两个皮肤管理

所以,我想把目录形式处理成Posted Image 这个形式!

参考了一下

http://www.yiiframew…234.html#msg234

在配置文件中配置themes,这儿激活的是整个 站点 的皮肤!

实际上我只需要在 mystoreController 中激活 我的店铺的 themes

请指教!

你指的是配置themeManager还是theme? 不管怎样,你都可以在mystoreController的init()函数配置它。给Yii::app()->theme或Yii::app()->themeManager赋值就行。

Quote

public function init()

{

parent::init();		





Yii::app()->themeManager->baseUrl =' /yii/WebRoot/member/themesStore';

}

public function actionIndex(){

     $this->render('index');

}

执行后发现,它仍是指向了默认视图

D:\www\yii\WebRoot\member\protected\views\layouts\main.php(28)

在actionIndex中发现,用Yii::app()->themeManager->getBaseUrl(),

实际上是改变了 变成了 /yii/WebRoot/member/themesStore

你指定theme了么?指定的theme目录下有views\layouts\main.php文件么?

问题解决了!

但是有个疑问

Quote

public function init()
{	





	//Yii::app()->themeManager->setBaseUrl('/yii/WebRoot/member/themesstore');





	Yii::app()->themeManager->setBasePath('d:/www/yii/WebRoot/member/themesstore');





	Yii::app()->theme = 'bh001';		





	//var_dump(Yii::app()->themeManager->getTheme('bh001')->getLayoutPath());





	//exit;





}</div></div>

init中使用 setBasePath 这个方法时,是正确的

      使用 setBaseUrl 这个方法时,结果确不正确!

setBasePath  是设置的一个绝对路径 setBaseUrl 设置的是一个url

为什么会有这样的差异呢!

之前一直错误的原因是因为我使用 setBaseUrl 方法

啊,是这样。BasePath决定了view和layout文件从哪里取,而BaseUrl仅仅用于生成theme所对应的URL。

setBasePath('d:/www/yii/WebRoot/member/themesstore')后

getBasePath() 结果改变了

getBaseUrl()获取时,仍是 /yii/WebRoot/member/themes

是的,你还需要设置baseUrl.

thanks!