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:
$this->renderPartial('//B/index')
but I get “The ‘dataProvider’ property cannot be empty.” So then I tried adding dataProvider:
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.
Don’t do it that way, use path aliases (this will render index.php view of B model)
$this->renderPartial('app.views.B.index');
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
$this->renderPartial('app.views.B.index',array('model'=>$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
$this->render('myview',array('BCONTENT'=>$content));
*** 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(‘app.views.global.messages’,array(‘type’=>‘error’,‘message’=>‘My error’));