Yii Theme Layout

In this post, I exaplained the method for “How to set the different layout from theme”

Using yii layout concept we can change our theme layout with different styles from current theme.

The basic syntax is

$this->layout="fullwidth"

“fullwidth” is layout file inside the “theme/views/layouts/” folder. It is working fine in lot of my project and also created problem in some project. The problem is, it is not getting the proper layout file path from my current theme. So i applied another method to assign the layout of my current theme.

$layoutname="fullwidth";
$ThemeLayout = 'webroot.themes.'.Yii::app()->theme->name.'.views.layouts.'.$layoutname;  
if($this->getLayoutFile($ThemeLayout) !== false){
       $this->layout = $ThemeLayout

It is working fine and solved my layout problem.