Reputation: 1211
What i am trying to do is to have this CGridView inside of the Yii framework get Data from my Image table from the database where it consist of imageUrl and imageExtension tables. Now i want to just display the actual image form the directory then just the text.
Meaning i have to join imageUrl and imageExtension together and also make the path in front to display the image tag.
Is this possible with the CGridView?
Here is my CGridView code:
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'image-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'imageUrl',
'imageExtension',
array(
'class'=>'CButtonColumn',
),
),
));
Upvotes: 0
Views: 203
Reputation: 14459
You can customize CGridView
columns.
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'image-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
array(
'header'=>'MY IMAGES',
'name'=>'imageUrl',
'value'=>'CHtml::image($data->imageUrl.$data->imageExtension)',
'type'=>'raw'
),
array(
'class'=>'CButtonColumn',
),
),
));
By the following array:
array(
'header'=>'MY IMAGES',
'name'=>'imageUrl',
'value'=>'CHtml::image($data->imageUrl.$data->imageExtension)',
'type'=>'raw'
),
You tell yii, to build a column with MY IMAGES
header and show the value of column as an image with: 'value'=>'CHtml::image($data->imageUrl.$data->imageExtension)'
. 'type'=>'raw'
means that you are trying to tell yii, not to show the text.
Upvotes: 2