widget.toString() ?

Is there a way to instantiate a widget and then get back the html as a string?



$widget = new CWidget();


$stringzz = $widget->toString();

Are you trying to get the widget's rendering result?

You may use output buffering (ob) to capture that.

Or you can use the following:



$this->beginClip('widget');


$this->widget('MyWidget');


$this->endClip();


// now the result can be accessed via $this->clips['widget']


excellent, thanks qianq