Get Html Output Into A Variable

Hi

How can I capture a part output of html code into a variable without ob_start and ob_get_contents etc but only using Yii Api?

for example I want like that


$this->beginContent('...',true); ?>

...html code here...

<?php $myvariable = $this->endContent(); ?>

I want the $myvariable to contains all the …html code here… without output anything of this part

I found something similar in http://www.yiiframework.com/doc/api/1.1/CController#renderPartial-detail with $processOutput=true

but I want it for a part o view not entire view

Thanks

If you can encapsulate the code in a widget, you can capture the output of that using the third parameter. See here.

Hi Keith

Did you find out which widget is appropriate for that issue?

for example


$this->beginWidget('zii.widgets.CPortlet','',true); ?>

    ...html content here...

<?php $this->endWidget();

the CPortlet decorates the content, but I want to get the pure content. Or better I sould to make my own widget?

Thanks for your response :)

I found a solution by clips


$this->beginClip('myvar'); ?>

 ...html content here.

<?php $this->endClip();


$myvar= $this->clips['myvar'];



If anyone find another solution please post :)

I meant to write your own widget, but clips are probably more appropriate.

Ok Keith, Thanks for your advice :)