show first part of a text

Hi

I would like to know if there is a way (with the framework) to print in the search wiew just a part a text.

for example,I have





<?php $this->widget('zii.widgets.grid.CGridView', array(

	'id'=>'news-grid',

	'dataProvider'=>$model->search(),

	'filter'=>$model,

	'columns'=>array(

		'id',

		'title',

		'text:html',

		'created',

                 array(

                    'name'=>'image',

                    'type'=>'html',

                    'value'=>'CHtml::image("/images/news/".$data->image."", "image", array("width"=>100))',

                

                ),

		'visible',

		array(

			'class'=>'CButtonColumn',

		),

	),

)); ?>






i would like ti know if there is a way to show just the first 200 characters of the field ‘text:html’,

or should I modify as Chtml and us e some normale php functions?

thank you

Paolo

I don’t think there is such function in Yii.

And don’t modify CHTML directly, but create new class that extends it, and modify that function there, so you would be able to upgrade Yii framework in future.

Well, the answer to your question is so obvious and simple, that I fear that I misunderstood you, and your asking about something completely different! :]

Actually, you’ve already solved yourself, but with the image column - i.e. use the same approach, i.e. using value parameter. So, instead of (part of your columns array):


'text:html'

use something like that:


array(

 		'name'=>'text',

 		'type'=>'html',

 		'value'=>'substr($data->text, 1, 200)',

 ),

(written from memory, not tested, but should work)

Is this, what you’re talking about?