Hi,
I have some problem about using Yii theming. I put it in the StackOverflow, but I’ll also attach the question here.
Hi,
I have some problem about using Yii theming. I put it in the StackOverflow, but I’ll also attach the question here.
Hi,
Here is the way I handled this.
The problem: If a view is not available in a theme, the application will use the default view outside the theme but it will continue to use the layout in the theme because the layout was found in the theme.
One possible solution: If a view is not found in the theme tell the application to stop using the theme.
My controllers extend a base controller (MyBaseController) which itself extends CController. Putting this code here in MyBaseController allows me to write this code only once. With this code the application will detect if a view is available for the current theme and if a view is not available then it will stop using the theme.
protected function beforeRender($view)
{
// if view is not found in the theme, do not use the theme's layout
if(($theme = Yii::app()->getTheme()) !== null && ($theme->getViewFile($this,$view)) === false)
{
Yii::app()->theme = null;
}
return true;
}