How do you embed a widget in a widget?

I’d like to embed a widget inside a widget…

Basically I want to use CTabView to create 3 tabs. I want each of those tabs to contain a CListView. I have been able to create the CListViews that I want, but I can’t figure out how to set them as the value for the content attribute of the tab.

Is it even possible to do this?

Basically if I try something like this…

$Tabs = array

           (


              'tab1'=>array('title'=>'Tab 1 Title','content'=>$this->widget('zii.widgets.CListView', array(


'dataProvider'=>$aDataProvider,


'itemView'=>'/someview/_view',

))),

           );

$this->widget(‘CTabView’, array(‘tabs’=>$Tabs, ));

I get this error…

"Object of class CListView could not be converted to string"

so I am guessing the render function on CListView is not being called.

Another alternative that would work for my interface would be to embed the CListViews into a CJuiAccordion, but again I can’t figure out how to set the panel content to be the CListview widget.

I have also tried using CClipWidget like this:

<?php $this->beginWidget(‘system.web.widgets.CClipWidget’, array(‘id’=>‘My tab 1’)); ?>

Tab 1 content

<?php $this->endWidget(); ?>

only I can’t figure out how to get the other widget content inside…

If I replace "Tab 1 Content" with

$this->widget(‘zii.widgets.CListView’, array(

'dataProvider'=&gt;&#036;vaDataProvider,


'itemView'=&gt;'/something/_view',

));

It just outputs that code as text rather than processing it first…

Problem solved… I used CClipWidgetand put the php open/close tags around the widget content as below.

<?php

$this->widget(‘zii.widgets.CListView’, array(

'dataProvider'=&gt;&#036;vaDataProvider,


'itemView'=&gt;'/something/_view',

));

?>

Try


$Tabs= array(

    'tab1'=>array('title'=>'Tab 1 Title',

        'content'=>$this->widget('zii.widgets.CListView', array(

            'dataProvider'=>$aDataProvider,

            'itemView'=>'/someview/_view',

        ),true)),

    );

There is a third option in the widget function that captures and returns the output of the widget if set to true.

http://www.yiiframework.com/doc/api/1.1/CBaseController#widget-detail