php - 如何在两条记录后添加 HTML 元素 zii.widgets.CListView widget Yii

标签 php html css yii

 <?php $this->widget('zii.widgets.CListView', array(
    'dataProvider'=>$dataProvider,
    'summaryText'=>'',
    'itemView'=>'_view',
)); ?>

我需要像

这样的输出
__________________________
ID   : 10    ID   : 11
Name : XXX   Name : YYYY
Age  : 15    Age  : 20
Place: abc   Place:xyz
--------------------------
ID   : 12    ID   : 13
Name : aaa   Name : sss
Age  : 24    Age  : 27
Place: vvc   Place:xzss
--------------------------

如何为此更改我的 _view.php

这是为了凭证打印,所以我需要降低纸张成本,所以我寻求这个解决方案。

最佳答案

您可以使用 Mohit Bhansali 发布的 HTML。但是您必须先添加一些 CSS:

.view {
    float: left;
    width: 250px; /* or other width */
}

然后在您的 _view.php 中,您清除 float 在顶部的每个第二项。您可以使用预定义的 $index 变量:

<?php if($index!=0 && $index%2==0): ?>
    <div style="clear:left"></div>
<?php endif; ?>

关于php - 如何在两条记录后添加 HTML 元素 zii.widgets.CListView widget Yii,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17860335/

相关文章:

html - 如何在表格标题内垂直居中对齐图标

html - 检测内容中的分页符

html - 即使在使用显示 :inline-block 后,社交媒体图标也不会出现在一行中

html - 重复字符串直到行尾

php - 如果文件大于给定大小,则阻止从远程源加载

javascript - HTML - 发票 : How to add values to text field and calculate total

php - 查询构建器条件参数

javascript - CSS3 样式属性中的 boolean 值

php - 需要Drupal多个自定义字段,如果字段为空则通过验证

php - 使用PHP和Android访问mysql数据库