renderPartial ???

Hello, all I’m trying to do is display a view from one or more models (B,C,D) in another view (A). So I’m on Page A, and I want to display the index pages of B, C, and D. How would I do this? I tried something like the following on the view.php page for A:


but I get “The ‘dataProvider’ property cannot be empty.” So then I tried adding dataProvider:

$dataProvider=new CActiveDataProvider('B');




But that gives me: “B.xxxx is not defined”, since it’s trying to access A’s properties. I can’t really find any examples on this that work for me. Any help is appreciated, thanks.

You can do only the render partial, you should copy all the code of the controller, prepare the model and then do the render partial.

Anyway is a quite bad practice to render a view of another model, if you need a piece of code to be reused is much better to create a widget.

So the best way to put in multiple views from a different controller is to create widgets? Thanks.

Don’t do it that way, use path aliases (this will render index.php view of B model)


Now, do you need to set a variable in there or a model?

// assuming you have a $model variable in the view and

// $model is a working model


Do you wish to display that on another view?

$content = $this->renderPartial('app.views.C.index', array('variablename'=>$whatever),true);

// I am going to display $content into another view


*** I totally agree with Zac’s comment, I highly recommend you that you do not use the view of another model, create another view (I have one in protected/views/global/messages.php that I use to display custom ajax Error messages: $this->renderPartial(‘’,array(‘type’=>‘error’,‘message’=>‘My error’));

Hope it helps

Hello, @Antonio Ramirez ::) im really grateful for the explanation, i actually needed this ;) ;)


I want to add task/admin in site/index view.

I have done like this


It’s working.

But, In task/admin, below code gives error "SiteController cannot find the requested view "_search". "




So i have changed it to (In /task/admin)




So I want to know that, Is this proper way to do it?

My admin view edit, view, delete link are current controller link

e.g. i have added /task/admin in site/index so links are

Edit :: urltoapplication/site/update/5

View :: urltoapplication/site/5

how to change them to task controller?