Newbie: Change Yii CRUD structure

Hi there,

I am building a simple site that allows you to post photos with a simple description. There are only two pages—the view of the photos as a list (I don’t need to see individual records) and the “create” page. Simple enough.

The problem is that I would like the "create" page to pop up on top of the view page as a sort of lightbox, so that when somebody submits a photo they can do so right there.

What is the sanctioned way of going about this? Right now I have created the "overlay" div inside /layouts/main.php. Then using JQuery, I make the overlay visible and tell it to load "".

The problem is that this then loads the entire main.php layout again within the overlay (header, logo and all). How can I override this so that it just loads the create page? I could tell it to load the create page’s view directly but then that would be missing out the Controller and the MVC structure.

Thanks for any help you can give,


In your Post controller and create action you can add:

$this->layout = null;

and main.php will not be used.

Ah, okay, that would make sense, but where exactly would I put that so that it only affects the "create" part of the Post, and not the View?



Also to point out—I have added that code into the ActionCreate function, but it still appears to pull from main.php. Here’s my code:

	public function actionCreate()


		$this->layout = null;

		$model=new Post;

		// Uncomment the following line if AJAX validation is needed





			if ($model->validate()) {


				$uploadedImage = CUploadedFile::getInstance($model, 'image');

                $savefilename = Yii::app()->basePath . '/../images/' . $model->photo_url;


				if($model->save(false)) // False because $model->save() validates the form and we have already done this with $model->validate









Why not just use renderpartial instead of render?

Reason is next line in code:


because you redirect user to viewAction, which probably use layout. Maybe you can add additional params, when redirect, and according to this parameter disable or enable layout in viewAction…