Reputation: 125
how to display image for a particular record??? my _view.php file is
<div class="view">
<b><?php echo CHtml::encode($data->getAttributeLabel('id')); ?>:</b>
<?php echo CHtml::link(CHtml::encode($data->id), array('view', 'id'=>$data->id)); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('name')); ?>:</b>
<?php echo CHtml::encode($data->name); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('product')); ?>:</b>
<?php echo CHtml::encode($data->product); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('category')); ?>:</b>
<?php echo CHtml::encode($data->category); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('image')); ?>:</b>
<?php echo CHtml::encode($data->image);
?>
<br />
I want to display images for each record on CListView... I qble to display image in CDetailView but i dont know how to display image in CListView....
help me please.. Thanks in advance
Upvotes: 0
Views: 1038
Reputation: 7265
you can use CHtml s image
Generates an image tag.
public static string image(string $src, string $alt='', array $htmlOptions=array ( ))
Update:
<?php echo CHtml::image(Yii::app()->baseUrl."/images/".$model->image.$data->image,$data->image , array(
'style' => 'max-height:40px',// set all sorts of styles here
'class' => 'someClass',
)); ?>
Upvotes: 1