Layout problem

Hi,

I have my SiteController like this: -




<?php


	class SiteController extends Controller {

		

		public function actionIndex() {

			

			$this->render("hello");

			

		}

		

		public function actionError() {

			

			echo("Hello Error!");

			

		}

		

	}


?>



And I also have my views layout in "views/site/main.php": -




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">


	<html xmlns="http://www.w3.org/1999/xhtml">


		<head>

		

			<title><?php echo CHtml::encode($this->pageTitle); ?></title>

			<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />

			<link href="<?php echo Yii::app()->request->baseUrl; ?>/css/style.css" rel="stylesheet" type="text/css" />

			

		</head>

		

		<body>

		

			<div id="menu">

			

				<a href="#">Log in</a>

			

			</div>

			

			<div id="submenu">

			

				<a href="#">Clients</a>

			

			</div>

			

			<div id="content">

			

				<div id="left">

				

					<?php echo $content; ?>

					

				</div>

				

				<div id="right">

				

					<p>Sidebar</p>

				

				</div>

				

			</div>

	

		</body>


	</html>



And only the controller action is showing up but not the layout. Any ideas anyone?

to set up the layout path you need to initialize a public variable in the controller class

like




class MyController extends CConttroller{

 	public $layout='site/main';

}



there’s a lot of ways to set its path, you might want to dig into it a little deeper.

for example, if you are using modules, and you want to use a common layout that is located under application.views.layouts set the layout path this way , using double slashes




 	public $layout='//layouts/main';



I’m not sure about which layout path it uses as default, so you might want to check it out on the class your controller extends from

Cheers for the reply, it works now :)