重点是从 CListView 渲染中移除这两个 div:
<div id="yw0" class="list-view">
<div class="items">
我一直在看这里:
https://github.com/yiisoft/yii/blob/master/framework/zii/widgets/CBaseListView.php#L123
但我在那里没有发现与这两个 div 相关的内容。
谁能分享一下,我们应该扩展什么才能实现这一点?
这是所需输出的更新:
<div>
<article class="itemthing">
list data
</article>
<article class="itemthing">
list data
</article>
<article class="itemthing">
list data
</article>
</div>
最佳答案
您最好从 CListView 本身扩展,但为 run()
编写新的实现 method in CBaseListView和 renderItems()
的新实现 method in CListView ,例如:
Yii::import('zii.widgets.CListView');
class MListView extends CListView{
public function run(){
$this->registerClientScript();
// this line renders the first div
//echo CHtml::openTag($this->tagName,$this->htmlOptions)."\n";
$this->renderContent();
$this->renderKeys();
//echo CHtml::closeTag($this->tagName);
}
public function renderItems(){
//this line renders the second div
//echo CHtml::openTag($this->itemsTagName,array('class'=>$this->itemsCssClass))."\n";
// copy original code from the function
//echo CHtml::closeTag($this->itemsTagName);
}
}
编辑:
请注意,某些默认的 clistview 功能仅适用于此,因为 jquery.yiilistview.js没有标识此 ListView 的 ID 将无法工作。
编辑:
根据您更新的问题,您可以这样做,然后:
<div id="some-id">
<?php
$this->widget('ext.extendedwidgets.MListView',array(
'id'=>'some-id', // same id you specified in the div
//... rest of it
'template' => '{items}', // as seen in the chat below
));
</div>
关于yii - 如何扩展 CListView 以删除额外的 yii 添加标记?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12298209/