I assume your message history that have order like this
user1: Hi Pete!
--------------------------------
user2: Hi Michael!
user2: Do you think about our plan yet?
--------------------------------
user1: Yes, I do.
Those records in the Message table look like
-----------------------------------------------------------
msg_id | msg | user_id (FK)
-----------------------------------------------------------
12004 Hi Pete! 1
12005 Hi Michael! 2
12006 Do you think about our plan yet? 2
12007 Yes, I do. 1
Add one property $show_line
into your Message
model and don't forget to make it as safe
attribute
$list_msg = Message:model->findAll(); // could be changed by your way to fetch all of messages & sort them by order of message
if(count($list_msg)>2){
for($i=0; $i<count($list_msg);$i++){
if($i < count($list_msg)-1){
//check if owner of current message item is owner of next message also
$list_msg[$i]->show_line = $list_msg[$i]->user_id == $list_msg[$i+1]->user_id; // user_id in my case is FK on Message table. I am not sure what it was in your db but you can customize it to appropriately
}
}
}
//$dataProvider = new CArrayDataProvider('Message');
//$dataProvider->setData($list_msg);
$dataProvider=new CArrayDataProvider($list_msg, array(
'id'=>'msg',
'sort'=>array(
.....
),
'pagination'=>array(
'pageSize'=>20,
),
));
Set that DataProvider
into your list view
Then in your item view, you shall capture the boolean show_line to display or hide the hr
line
<?php if($data->show_line) {?> <hr .../> <?php } ?>
Above is one way how to make it work, it couldn't match your code exactly.