Reputation: 14707
I wanted to modify the default list view provided by the Yii framework. The current view display everything as a row . What I want is to display the information in following format
. Could you suggest me how can I extend this widget and create my own view. I have attached both needed as a image. I am new to Yii so all help would be really appriciable. If there is already any widget in this format I would be so happy.
Content for my view File would be
<?php
/* @var $this LeosafealertController */
/* @var $data Leosafealert */
?>
<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('date')); ?>:</b>
<?php echo CHtml::encode($data->date); ?>
<br/>
<b><?php echo CHtml::encode($data->getAttributeLabel('description')); ?>:</b>
<?php echo CHtml::encode($data->description); ?>
<br/>
<b><?php echo CHtml::encode($data->getAttributeLabel('photo')); ?>:</b>
<?php echo CHtml::image($data->getImageURL().$data->photo,$data->photo); ?>
</br>
<b><?php echo CHtml::encode($data->getAttributeLabel('link')); ?>:</b>
<?php echo CHtml::link(CHtml::encode("click here"), $data->getFileURL().$data->link,array('target'=>'_blank')); ?>
</div>
Upvotes: 3
Views: 3873
Reputation: 4150
Can you not edit your view file (e.g. just edit '/path/to/model/views/_view.php', or whatever your view file is called)?
You can also declare your own css file for a CLitView by defining a cssFile property. ie;
$this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'itemView'=>'_view',
'cssFile'=>'/css/myCssFile.css',
...
));
You could create your own css file for your layout and use that for every CListView you want with the given layout?
Upvotes: 1