show first part of a text


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(












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








)); ?>

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


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):


use something like that:




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


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

Is this, what you’re talking about?