Hello,
I store imagename with path in db. Now i want to redenr image in listing page but it shows image name. Below is the code to generate list. Pl help.
<?php
$this->beginWidget('zii.widgets.CPortlet', array(
'title'=>"Agent List",
));
?>
<?php $this->widget(‘zii.widgets.grid.CGridView’, array(
'id'=>'agent-new-grid',
'itemsCssClass'=>'table table-hover',
'dataProvider'=>$model->search(),
'template'=>"{items}",
'filter'=>$model,
'columns'=>array(
'id',
'name',
'propName',
'logo', //returns image path along with name.
'address',
array(
'class'=>'CButtonColumn',
),
),
)); ?>
<?php $this->endWidget();?>
Hi All,
After going through various topics in forum. i modified the above code to:
<?php $this->widget(‘zii.widgets.grid.CGridView’, array(
'id'=>'agent-new-grid',
'itemsCssClass'=>'table table-hover',
'dataProvider'=>$model->search(),
'template'=>"{items}",
'filter'=>$model,
'columns'=>array(
'id',
'name',
'propName',
array(
'name'=>'logo',
'type'=>'image',
'value'=>$_SERVER['HTTP_HOST'].Yii::app()->request->baseUrl.'"/images/agents/"'.$model->id.'"_"'.$model->logo,
),
'address',
'active',
array(
'class'=>'CButtonColumn',
),
),
)); ?>
Now it returns me empty img tag as <img alt="" src="" >
abennouna
(Abennouna)
3
And like this?
array(
'name' => 'logo',
'type' => 'image',
'value' => "$_SERVER['HTTP_HOST'] . Yii::app()->request->baseUrl . '/images/agents/' . $data->id . '_' . $data->logo",
),
More info: http://www.yiiframework.com/doc/api/1.1/CDataColumn#value-detail
fburhan89
(Sefburhan)
4
array(
'name'=>'hotel_image1',
'type'=>'html',
'value'=>'CHtml::image(Yii::app()->baseUrl . "/images/hotel/" . $data->hotel_image1,$data->hotel_name,array("class" => "logo", "title" => $data->hotel_name, "width"=>"100", "height"=>"80"))',
'htmlOptions' => array(
'style' => 'margin:2px 5px 2px 5px; width:100px;',
),
),